Marie-Andree
Member
- Joined
- Sep 9, 2015
- Messages
- 8
- Programming Experience
- Beginner
Hello,
My name is Marie and I am new to VB.Net. I am trying to work on this school assignment and I am struggling a bit. I need to display in a combo box names coming from a .txt documents. For example the text document goes as follow:
Would it be possible to guide me in the right direction?
Dave
781-294-8544
723-295-8533
735-296-8511
450-297-8523
Dave@gmail.com
Marie
780-888-1234
123-123-1234
888-777-5555
444-222-8888
Marie@gmail.com
Once the names are displayed in the combo box, I need to select one to display the relates information in text boxes (phone, cell...)
Here is what I have so far:
My name is Marie and I am new to VB.Net. I am trying to work on this school assignment and I am struggling a bit. I need to display in a combo box names coming from a .txt documents. For example the text document goes as follow:
Would it be possible to guide me in the right direction?
Dave
781-294-8544
723-295-8533
735-296-8511
450-297-8523
Dave@gmail.com
Marie
780-888-1234
123-123-1234
888-777-5555
444-222-8888
Marie@gmail.com
Once the names are displayed in the combo box, I need to select one to display the relates information in text boxes (phone, cell...)
Here is what I have so far:
Imports System.IO Public Class BlackBookLookupForm Dim BlackBookStreamReader As StreamReader Dim lineCounter As Integer = 0 Dim Line As String 'Friend Structure peopleInfo ' Dim NameString As String ' Dim PhoneString As String ' Dim PagerString As String ' Dim CellString As String ' Dim VoiceMailString As String ' Dim EmailString As String 'End Structure Dim xIndexInteger As Integer 'Dim objPeopleInfo(1000) As peopleInfo 'objPeopleInfo = BlackBookStreamReader 'Private Sub DisplayPeopleInfo(ByVal people As peopleInfo) ' TextBoxPhone.Text = BlackBookStreamReader.ReadLine() ' TextBoxPager.Text = BlackBookStreamReader.ReadLine() ' TextBoxCell.Text = BlackBookStreamReader.ReadLine() ' TextBoxVoiceMail.Text = BlackBookStreamReader.ReadLine() ' TextBoxEmail.Text = BlackBookStreamReader.ReadLine() 'End Sub Private Sub OpenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles OpenToolStripMenuItem.Click Dim ResponseDialogResult As DialogResult With OpenFileDialog1 .InitialDirectory = Directory.GetCurrentDirectory() .FileName = "*.txt" .Title = "Select File or Directory for file." ResponseDialogResult = .ShowDialog() End With If ResponseDialogResult <> DialogResult.Cancel Then BlackBookStreamReader = New StreamReader(OpenFileDialog1.FileName) End If Do Until BlackBookStreamReader.Peek = -1 'Line = BlackBookStreamReader.ReadLine() ComboBoxChooseFile.Text = BlackBookStreamReader.ReadLine 'ComboBoxChooseFile.Text = BlackBookStreamReader.ReadLine() 'How to have everithing 'ComboBoxChooseFile.Items.Add(BlackBookStreamReader.ReadLine) lineCounter = lineCounter + 1 Loop End Sub Private Sub DisplayPeopleInfo() End Sub Private Sub ComboBoxChooseFile_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBoxChooseFile.SelectedIndexChanged If BlackBookStreamReader.Peek <> -1 Then DisplayPeopleInfo() Else MessageBox.Show("No record to display") End If End Sub Private Sub ExitToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click If BlackBookStreamReader IsNot Nothing Then BlackBookStreamReader.Close() End If Me.Close() End Sub End Class
Last edited by a moderator: