Sinisterly
[save] Need some help saving listbox without showing save dialog [VB.NET] - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework)
+--- Thread: [save] Need some help saving listbox without showing save dialog [VB.NET] (/Thread-save-Need-some-help-saving-listbox-without-showing-save-dialog-VB-NET)

Pages: 1 2


RE: Need some help with something [VB.NET] - 1234hotmaster - 01-19-2011

Code:
If TextBox1.Text.Contains("chrome") And ListBox1.Items.Contains(TextBox1.Text) = True Then Process.Start(TextBox1.Text)

tested and working. hope this works Smile


RE: Need some help with something [VB.NET] - Coder-san - 01-19-2011

Glad it worked, however take note that this is currently case-sensitive.
For making it case-insensitive, store process names in either Lowercase or Uppercase, then change the line of code accordingly.

Example:

If ListBox1.Items.Contains(TextBox1.Text.ToLower) = True Then Process.Start(TextBox1.Text)


RE: Need some help with something [VB.NET] - 1234hotmaster - 01-19-2011

i understand its not an IRC but the thing is, HC is missing an IRC like some other Hack forums.

-----------------------------------------------------------------------------------------------------------

@the thread starter
is your problem solved yet?
if no ask any questions.


RE: [save] Need some help saving listbox without showing save dialog [VB.NET] - 1234hotmaster - 01-19-2011

@threadstarter

You can use this:
Code:
TextBox1.Multiline = True TextBox1.Visible = False TextBox1.Text = ListBox1.Items.Item(1) Dim ftr As New FileStream("C:\listbox.txt", FileMode.Create, FileAccess.Write) Dim stw As New StreamWriter(ftr) stw.BaseStream.Seek(0, SeekOrigin.End) stw.Write(TextBox1.Text) stw.Close()

but sadly... it will write only the first line... you can wait for coder till tomorrow anyways.
sage or anyone else, if you know how to make ListBox1.Items.Item(0 to 10000000000000) in coding i think his problem is solved...
PS: i already tried
"For intadd as integer = 1 to 1000 step 1
ListBox1.Items.Item(intadd)
Next"
but it gives error...


RE: [save] Need some help saving listbox without showing save dialog [VB.NET] - FrostByte_mybb_import5923 - 01-19-2011

edit: i tryed editing the codes to suit my befits if anyone is able to help with this then please say.


RE: [save] Need some help saving listbox without showing save dialog [VB.NET] - 1234hotmaster - 01-19-2011

your welcome but in the end u need to wait for Coder-san for a working code Tongue

also you can post new threads for topics that are not related to eachother just don't spam cause sage just changed his mood from "Web Veteran" to "I'm Watching You" *Gulp*

btw... sadly you can't get the whole listbox with simple codes. if you try listbox1.items.tostring you will see a text saying "{Collection}" instead of the item's text. and if listbox1.items.item(1) you can only select 1 item like (1) means Item Number 1.


RE: [save] Need some help saving listbox without showing save dialog [VB.NET] - Coder-san - 01-20-2011

Or this:

Code:
Dim theOutput As String = String.Empty For Each item In ListBox1.Items theOutput &= item & vbCrLf Next IO.File.WriteAllText("C:\new.txt", theOutput)

But Sage's way is faster. Because it does not concatenate strings.


RE: [save] Need some help saving listbox without showing save dialog [VB.NET] - FrostByte_mybb_import5923 - 01-22-2011

hey i asked about this a while ago and the sage and coder sam both gave me codes to save without showing the showfiledialog but the problem with them both is they do not save the text within the listbox they just create the specified text file can you guys help me so it saves the text within the listbox into the text file


RE: [save] Need some help saving listbox without showing save dialog [VB.NET] - 1234hotmaster - 01-22-2011

what you mean they still don't work? sage's code works and i tested it Smile

Code:
Dim i As Integer = 0 Dim fs As New FileStream("C:\lstboxsave.txt", FileMode.Create, FileAccess.Write) Dim s As New StreamWriter(fs) s.BaseStream.Seek(0, SeekOrigin.End) While i < ListBox1.Items.Count s.WriteLine(ListBox1.Items(i).ToString()) i = i + 1 End While s.Close()

nice coding sage :thumbs:


RE: [save] Need some help saving listbox without showing save dialog [VB.NET] - Coder-san - 01-22-2011

Yes, I use the code I posted + file search to add the Contents part in my threads.