So I play a browser based game and I thought about using VB to help me.
I am alas not very experienced in vb so please don't be too technical in your ideas![]()
My first problem is to load records from a text file into a list box : I did manage to do that but each record in the text file is in a line while in the list box, it isn't.
Also I get some squares in occasional places. How to solve this ?
Here's my code:
here is what happens:Code:Private Type OneKingdom KingdomID As Integer Name As String * 30 Planet As String * 25 Land As String * 6 Networth As String * 10 Honor As String * 4 End Type Dim Filename As String Dim NumberOfRecords As Integer Private Sub cmdDisplayFile_Click() Dim Index As Integer Dim DataToDisplay As String 'details of one KD Dim Name As String * 30 Dim Planet As String * 25 Dim Land As String * 6 Dim Networth As String * 10 Dim Honor As String * 4 Dim Kingdom As OneKingdom Filename = txtFilename.Text lstdisp.Clear Open Filename For Random As #1 Len = Len(Kingdom) For Index = 1 To NumberOfRecords 'loop through KDs in file Get #1, , Kingdom Name = Kingdom.Name Planet = Kingdom.Planet Land = Kingdom.Land Networth = Kingdom.Networth Honor = Kingdom.Honor DataToDisplay = Kingdom.Name & " " & Planet & " " & Land & " " & Networth & " " & Honor & " " & Stuff & " " lstdisp.AddItem DataToDisplay Next Index Close #1 End Sub Private Sub cmdSelectFile_Click() Dim Kingdom As OneKingdom 'one record CommonDialog1.Showopen 'display the Open (file) dialog box txtFilename.Text = CommonDialog1.Filename 'display selected file name Filename = txtFilename.Text Open Filename For Random As #1 Len = Len(Kingdom) 'open file NumberOfRecords = LOF(1) / Len(Kingdom) 'calculate number of kindgoms in it lblrecords.Caption = NumberOfRecords Close #1 End Sub
![]()




Reply With Quote