vb.net textfile help.
Posted: Tue Jul 23, 2013 8:34 pm
Hello,
This is the code i use to load all my customers names from my text file in to the list box
This is my full code for my page.
This is the code i use to load all my customers names from my text file in to the list box
Code: Select all
how do i get it to show the selected item's name in to a text box.. Dim i As Short
lstDetails.Items.Clear()
For i = 1 To numrecs
With CustArray(i)
lstDetails.Items.Add(.CustName)
End With
Next
This is my full code for my page.
Code: Select all
Option Strict Off
Option Explicit On
Friend Class frmViewCust
Inherits System.Windows.Forms.Form
Dim numrecs As Short
Private Sub cmdMain_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdMain.Click
Me.Close()
frmMenu.Show()
End Sub
Private Sub cmdSearch_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSearch.Click
Dim i As Short
Dim searchname As String
lstDetails.Items.Clear()
searchname = InputBox("Enter name to search for", "Find Customer")
searchname = UCase(searchname)
For i = 1 To numrecs
With CustArray(i)
If searchname = .CustName Then
lstDetails.Items.Add(.CustName)
lstDetails.Items.Add(.Address)
lstDetails.Items.Add(.Town)
lstDetails.Items.Add(.Phone)
Exit Sub
Else : MsgBox("No record for this customer")
End If
End With
Next
End Sub
Private Sub cmdViewAll_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdViewAll.Click
Dim i As Short
lstDetails.Items.Clear()
For i = 1 To numrecs
With CustArray(i)
lstDetails.Items.Add(.CustName)
End With
Next
End Sub
Private Sub frmViewCust_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Dim Booking As BookingRecord
Filename = My.Application.Info.DirectoryPath & "\fish.dat"
FileOpen(1, Filename, OpenMode.Input)
Do While Not EOF(1)
numrecs = numrecs + 1
Input(1, Booking.DateOfBooking)
Input(1, Booking.BookingName)
CustArray(numrecs).CustName = Booking.BookingName
Input(1, Booking.BookingAddress)
CustArray(numrecs).Address = Booking.BookingAddress
Input(1, Booking.BookingTown)
CustArray(numrecs).Town = Booking.BookingTown
Input(1, Booking.BankOrBoatBooking)
Input(1, Booking.ContactPhoneNumber)
CustArray(numrecs).Phone = Booking.ContactPhoneNumber
Input(1, Booking.DayOrEveningSession)
Input(1, Booking.OutBoard)
Input(1, Booking.NumberFishing)
Input(1, Booking.BankOrBoatCost)
Input(1, Booking.OutboardCost)
Input(1, Booking.TotalCostForGroup)
Loop
FileClose(1)
End Sub
End Class