943,884 Members | Top Members by Rank

Ad:
Aug 8th, 2009
0

FRMREtrieve

Expand Post »
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, 6 views)
Reputation Points: 10
Solved Threads: 0
Light Poster
reyarita is offline Offline
26 posts
since Aug 2009
Aug 8th, 2009
0

Re: FRMREtrieve

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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: make excel to display in form like mdi.!pls..help
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: howtoadd combo box item in textbox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC