vb.net textfile help.
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
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
try this 

Code: Select all
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
For i = 0 To ListBox1.SelectedItems.Count - 1
TextBox1.Text = ListBox1.SelectedItems.Item(i).ToString()
Next
End Sub
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
i done this
Code: Select all
what if i wanted to show the rest of the information in textboxe's? Private Sub lstDetails_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstDetails.SelectedIndexChanged
Dim i As Integer
For i = 0 To lstDetails.SelectedItems.Count - 1
TextBox1.Text = lstDetails.SelectedItems.Item(i).ToString()
Next
End Sub
if it's a simple listbox (not a listview) try this:
Code: Select all
If it's a list view and the customer's name is the second row, use this:
Dim str As String = ListBox1.SelectedItem.ToString()
TextBox1.Text = str
Code: Select all
Dim str as string = ""
For Each lst as ListViewItem in lstView.SelectedItems
str = lst.Subitems(0).Text
Next
TextBox1.text = str
what i ment was i have the textbox1 working i was meaning i have a field called address etc and want to show that aswell once they select a name from the list box.?
ohh then use a ListView. select the View to Detail and then enter data to it. (Then extract the data as i told you)
it's just im trying to do it that way as its the last of a college project?.
THe items will look something like this
John Doe Acme, Inc. 14-Downtown
etc.. How ever, to give it a simple yet clean look:
Use uxtheme.dll (Vista and above) with the SetWindowTheme function.
John Doe Acme, Inc. 14-Downtown
etc.. How ever, to give it a simple yet clean look:
Use uxtheme.dll (Vista and above) with the SetWindowTheme function.
Copyright Information
Copyright © Codenstuff.com 2020 - 2023