FRMREtrieve

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2009
Posts: 6
Reputation: reyarita is an unknown quantity at this point 
Solved Threads: 0
reyarita reyarita is offline Offline
Newbie Poster

FRMREtrieve

 
0
  #1
Aug 8th, 2009
hey guys i need some a litle help with my vb.

i have a problem with my project
i cant delete a data in a file and i cant split the name,age and id if ever i click it, it will display above of it in FRMRETRIEVE

i have here all my code in the zip file


Private Sub cmdDelete_Click() // IHAVE ALSO PROBLEM
Dim i As Integer //WITH THIS DELETE
If rey.Text(lstData.List) = "true " Then //IT WILL NOT DELETE
If MsgBox("You want to delete this data" & rey.Text) Then
rey.RemoveItem (lstData.ListIndex)

Close #1
End If
End If

End Sub

Private Sub cmdRetrieve_Click()
Dim X As String
Open App.Path & "\rey.txt" For Input As #1
While Not EOF(1)
Line Input #1, X
lstData.AddItem (X)
Wend
Close 1
End Sub
Private Sub cmdSave_Click()
Dim i As Integer
i = lstData.ListIndex
lstData.List(i) = txtID.Text
lstData.List(i) = txtName.Text
lstData.List(i) = txtAge.Text
Open App.Path & "\rey.txt" For Output As #1
For i = 0 To lstData.ListCount - 1
Print #1, lstData.List(i)
Next i
Close 1
End Sub
Private Sub lstData_Click() // I HAVE A PROBLEM WITH THIS AREA
Dim i As Integer //IT WILL NOT SPLIT
//THE AGE,NAME & id
i = lstData.ListIndex // IF I WILL CLICK THE LISTDATA
txtID.Text = lstData.List(i) // IT WILL BE SPLIT IN THE ABOVE
txtName.Text = lstData.List(i)
txtAge.Text = lstData.List(i)
End Sub
Attached Files
File Type: zip Desktop.zip (5.9 KB, 3 views)
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 881
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 164
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: FRMREtrieve

 
0
  #2
Aug 8th, 2009
Okay, to split on the comma (,) you need to use...

THE Split Function!
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim MyArray() As String
  2. MyArray = Split(lstData.List(i), ",")
  3. txtID.Text = MyArray(0)
  4. txtName.Text = MyArray(1)
  5. txtAge.Text = MyArray(2)

Then would it not be lstData.RemoveItem(i)?

And now for why you are having so many problems...

Tools>Options>Put a check next to Require Variable Declaration>OK

In future projects this will put Option Explicit at the top of all your forms and modules and will make you declare your variables. This will solve a lot of problems for you. In fact, you could manually put it in at the top of your existing forms and modules and this will help you out by pointing out your mistakes.


Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC