namco_ (namco_) wrote in vbdev,
namco_
namco_
vbdev

I'll try to go through this as simply as I can as I don't know how complex this sounds. I'm using VB 6.0 and I'm developing a helper program for an old wargame called BattleTech, currently I have a main screen that lets you open a selector page for selecting only 4 robots from a pool of about 15 robots. The way you select is to double click the picture and that tells another form, which is also on screen, to add an item to its list box with just text saying the robot you selected ie if you double click the Robot Alpha picture an item appears with the text "Robot Alpha". Once all 4 robots are selected, and the selection screen is closed, you then select all the items in the listbox and click a button on that form which sends each list to an option button, on the main screen. The option button's caption is updated with each robot's name respectively ie the first robot on the list will go onto the first option button. These option buttons are in a control array and there are 4 of them.

This means that 1 robot could appear at least once at any of the 4 option buttons. What I would like the program to do is when the option button, for a robot, is clicked and a button is pressed it reads a file that contains information for walking, running and jumping and populates that into the text boxes i have on the main screen. I've already tried doing this numerous times only managing to get a little far with one robot. Here's the code I have so far


Dim tmpString As String
Dim ReadFrom As String

Private Sub cmdOpen_Click()
Dim a
Dim b
Dim c
Dim d

Close
Open "C:\Documents and Settings\J\My Documents\BattleTech pbem program\mech.dat" For Input As #1
For d = 0 To 3 Step 1
If frmBTechMain.optMech(d).Caption = "Commando COM-2D" Or (EOF(1) = True) Then
Close #1
Open "C:\Documents and Settings\J\My Documents\BattleTech pbem program\mech.dat" For Input As #1
ReadFrom = ""
Line Input #1, tmpString
If StrComp(ReadFrom, tmpString) = 0 Then
Do While tmpString <> "
"
Line Input #1, tmpString
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
frmBTechMain.txtWalking = tmpString
End If
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
frmBTechMain.txtRunning = tmpString
End If
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
If tmpString = "0" Then
frmBTechMain.lblJumping.Enabled = False
frmBTechMain.txtJumping.Enabled = False
frmBTechMain.txtJumping = tmpString
Else
frmBTechMain.txtJumping = tmpString
End If
End If
Loop
Else
Line Input #1, tmpString
End If
ElseIf frmBTechMain.optMech(d).Caption = "Spider SDR-5V" Or (EOF(1) = True) Then
Close #1
Open "C:\Documents and Settings\J\My Documents\BattleTech pbem program\mech.dat" For Input As #1
ReadFrom = ""
Line Input #1, tmpString
If StrComp(ReadFrom, tmpString) = 0 Then
Do While tmpString <> "
"
Line Input #1, tmpString
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
frmBTechMain.txtWalking = tmpString
End If
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
frmBTechMain.txtRunning = tmpString
End If
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
If tmpString = "0" Then
frmBTechMain.lblJumping.Enabled = False
frmBTechMain.txtJumping.Enabled = False
frmBTechMain.txtJumping = tmpString
Else
frmBTechMain.txtJumping = tmpString
End If
End If
Loop
Else
Line Input #1, tmpString
End If
ElseIf frmBTechMain.optMech(d).Caption = "Jenner JR7-D" Or (EOF(1) = True) Then
Close #1
Open "C:\Documents and Settings\J\My Documents\BattleTech pbem program\mech.dat" For Input As #1
ReadFrom = ""
Line Input #1, tmpString
If StrComp(ReadFrom, tmpString) = 0 Then
Do While tmpString <> "
"
Line Input #1, tmpString
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
frmBTechMain.txtWalking = tmpString
End If
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
frmBTechMain.txtRunning = tmpString
End If
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
If tmpString = "0" Then
frmBTechMain.lblJumping.Enabled = False
frmBTechMain.txtJumping.Enabled = False
frmBTechMain.txtJumping = tmpString
Else
frmBTechMain.txtJumping = tmpString
End If
End If
Loop
Else
Line Input #1, tmpString
End If
ElseIf frmBTechMain.optMech(d).Caption = "Panther PNT-9R" Or (EOF(1) = True) Then
Close #1
Open "C:\Documents and Settings\J\My Documents\BattleTech pbem program\mech.dat" For Input As #1
ReadFrom = ""
Line Input #1, tmpString
If StrComp(ReadFrom, tmpString) = 0 Then
Do While tmpString <> "
"
Line Input #1, tmpString
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
frmBTechMain.txtWalking = tmpString
End If
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
frmBTechMain.txtRunning = tmpString
End If
If StrComp(tmpString, "") = 0 Then
Line Input #1, tmpString
If tmpString = "0" Then
frmBTechMain.lblJumping.Enabled = False
frmBTechMain.txtJumping.Enabled = False
frmBTechMain.txtJumping = tmpString
Else
frmBTechMain.txtJumping = tmpString
End If
End If
Loop
Else
Line Input #1, tmpString
End If
End If
Next
Close #1
End Sub


Those Dim a,b,c,d have been left there as I had been messing around with nesting extra For...Next loops.

Sorry for the longness of this post and I hope I've given enough information. If not then please let me know.

Thanks very much!
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 0 comments