Hi forgive me im still new to vb.net and progging!!I have my app using tabpages thought it was easier for my project,
ontab 1 i have 2 text boxes with and output from other text boxes
I have a button to save to file this works great with snippets from you guys on here .
Now ontab2 i have a listbox the list box is populated from the saved text file works ok apart from the saved items from tab1 dont appear till the program is next run? I have hidden button3 as i have put the TabControl1.Enter there to trigger the button action as i wanted the list to load on clicking the tab not a button if you know what i mean?
The code im using is below if any body can help with away of it kind refreshing the file before populating thre list?
VB Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click, TabControl1.Enter ' Load the ListBox from a file. Try Dim file_name As String = DataFile() Dim stream_reader As New IO.StreamReader(Application.StartupPath & "\mysaved.txt") ListBox1.Items.AddRange(Split(stream_reader.ReadToEnd, _ vbCrLf)) ListBox1.SelectedIndex = 0 stream_reader.Close() Catch exc As Exception ' Report all errors. MsgBox(exc.Message, MsgBoxStyle.Exclamation, "Read " & _ "Error") End Try End Sub ' Return the data file name. Private Function DataFile() As String Dim file_name As String = Application.StartupPath If file_name.EndsWith("\bin") Then file_name = _ file_name.Remove(file_name.Length - 4, 4) file_name &= "\mysaved.txt" Return file_name End Function




I have my app using tabpages thought it was easier for my project,
tab 1 i have 2 text boxes with and output from other text boxes
Reply With Quote