« Cram time | Main | Yay, Gimp »
Hurdle cleared, onto the finish line
By Ravenhawk | December 6, 2006
Tada: My button works, the user can now only select a single score to apply to each stat. Now all that remains for my Visual Basic project is to finish the print page and to make myself a cool logo. Behold the mighty code that stumped me for weeks:
‘Set score from label to corresponding stat in the dropdown menu.
‘Only one of each dropdown allowed
Dim intcount As Integer, intnum As Integer, intcounter As Integer, intErr As Integer
Dim intindex As Integer, intresponse As Integer, intnumber As Integer
‘intcount = menus intnum = options
If blnScores = True Then
For intcount = 0 To 5
intindex = cbostat(intcount).ListIndex
For intnum = 0 To 5
If cbostat(intnum).Index cbostat(intcount).Index Then
If cbostat(intnum).ListIndex = intindex Then
intresponse = MsgBox(”Please select only One option”, vbOKOnly, “Character Generator”)
End If
End If
Next intnum
Next intcount
‘If not error was found, apply stats
If intresponse = vbOK Then
For intcount = 0 To 5 Step 1
cbostat(intcount).Text = “Select stat”
Next intcount
Else
For intcounter = 0 To 5
Select Case cbostat(intcounter).ListIndex
Case 0
intStr = intstat(intcounter)
Case 1
intDex = intstat(intcounter)
Case 2
intInt = intstat(intcounter)
Case 3
intCon = intstat(intcounter)
Case 4
intWis = intstat(intcounter)
Case 5
intCha = intstat(intcounter)
Case Else
intErr = MsgBox(”Invalid Statistic Selection”, vbOKOnly, “Character Generator”)
End Select
Next intcounter
blnStats = True
For intnumber = 0 To 5
Select Case intstat(intnumber)
Case 2 To 3
intmod(intnumber) = -4
Case 4 To 5
intmod(intnumber) = -3
Case 6 To 7
intmod(intnumber) = -2
Case 8 To 9
intmod(intnumber) = -1
Case 10 To 11
intmod(intnumber) = 0
Case 12 To 13
intmod(intnumber) = 1
Case 14 To 15
intmod(intnumber) = 2
Case 16 To 17
intmod(intnumber) = 3
Case 18 To 19
intmod(intnumber) = 4
Case 20 To 21
intmod(intnumber) = 5
End Select
Next intnumber
End If
Else
intErr = MsgBox(”Complete all previous steps before moving on.”)
End If
Until Next time, Comrades.
Tags: Programming, Visual Basic
Topics: Programming |








