Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use OptionButton instead of ComboBox
#1
Hello, Im pretty new to VB, and im trying to learn it.
Im trying to make all the Selection's (like male/female, pick character, Class selection) as pictures instead of those nasty "lists" etc...
So my question is: How can i set the Class selection as Option buttons?


This is the current one as a ComboBox but i need it in OptionButtons:

Code:
Private Sub cmbClass_Click()
    lblHP.Caption = STR(Class(cmbClass.ListIndex).HP)
    lblMP.Caption = STR(Class(cmbClass.ListIndex).MP)
    lblSP.Caption = STR(Class(cmbClass.ListIndex).SP)
    
    lblSTR.Caption = STR(Class(cmbClass.ListIndex).STR)
    lblDEF.Caption = STR(Class(cmbClass.ListIndex).DEF)
    lblSPEED.Caption = STR(Class(cmbClass.ListIndex).speed)
    lblMAGI.Caption = STR(Class(cmbClass.ListIndex).MAGI)
    
    lblClassDesc.Caption = Class(cmbClass.ListIndex).desc
Reply
#2
The way I would do it (although some may argue against it, it may be bad coding practice) is just make the images and when you click the image have it set cmbClass.ListIndex = 0. Or 1 or 2 or whatever. Then hide the combo box off the screen.
Reply
#3
Vegeta Wrote:The way I would do it (although some may argue against it, it may be bad coding practice) is just make the images and when you click the image have it set cmbClass.ListIndex = 0. Or 1 or 2 or whatever. Then hide the combo box off the screen.

hmmm, ok.
Reply
#4
Code:
If optClass1.value = 1 then
          cmbclass.listindex = 0
else
etc
etc

That's what Vegeta is talking about. It does everything you need it to do, without seeing the list box and it looking the exact way you asked about.
Reply
#5
Oh right Big Grin I got confused between pictures and option buttons haha.
Reply
#6
Vegeta Wrote:The way I would do it (although some may argue against it, it may be bad coding practice) is just make the images and when you click the image have it set cmbClass.ListIndex = 0. Or 1 or 2 or whatever. Then hide the combo box off the screen.

Dunno if its right but, i made three new Option Buttons....

Code:
Private Sub Option1_Click()
cmbClass.ListIndex = 0
End Sub

Private Sub Option2_Click()
cmbClass.ListIndex = 1
End Sub

Private Sub Option3_Click()
cmbClass.ListIndex = 2
End Sub

Im sure its 100% wrong? Smile
Reply
#7
yeah thats right Tongue
Reply
#8
Beres Wrote:yeah thats right Tongue

am i right that its 100% wrong or is it correctly done? Tongue

If its correct then, whats up with these values?

Code:
lblHP.Caption = STR(Class(cmbClass.ListIndex).HP)
    lblMP.Caption = STR(Class(cmbClass.ListIndex).MP)
    lblSP.Caption = STR(Class(cmbClass.ListIndex).SP)
  
    lblSTR.Caption = STR(Class(cmbClass.ListIndex).STR)
    lblDEF.Caption = STR(Class(cmbClass.ListIndex).DEF)
    lblSPEED.Caption = STR(Class(cmbClass.ListIndex).speed)
    lblMAGI.Caption = STR(Class(cmbClass.ListIndex).MAGI)
  
    lblClassDesc.Caption = Class(cmbClass.ListIndex).desc
Reply
#9
100% you are correct. Those values are assigned by when you click on a class. Since when you click on an option, its just like clicking in the combo box. So it should still assign those values.

EDIT: The STR(Class(cmbClass.ListIndex).HP) is basically the class. Lets say the listindex = 0. Thats Class0. It gets the stats from there.
Reply
#10
or replace this part
Code:
cmbClass.ListIndex
with a variable, like:
Code:
STR(Class(iIndex).SP)
And set iIndex to whatever char it is you pressed on.
Reply
#11
William Wrote:or replace this part
Code:
cmbClass.ListIndex
with a variable, like:
Code:
STR(Class(iIndex).SP)
And set iIndex to whatever char it is you pressed on.

But wouldnt it work just by leaving it as STR(Class(cmbClass.ListIndex).SP) or whatever.? I mean its just like clicking on the cmbClass itself and selecting a class. Except you're just settings its listindex by code..
Reply
#12
wow, tought i would be easy...
Just to copy the values from the Combox and paste into a Optionbox.

But if make the number of classes and i wont change them after that.
Would that be easyier?
Reply
#13
It's very easy, just doesn't seem like you know the basics. Is suggest you read some tutorials to learn about variables and such.
Reply
#14
If you have a base set amount of classes, and you're not going to change it anytime soon, it's really simple.

Code:
private sub optClass1_click()
          cmbClass.listindex = 0
end sub

private sub optClass2_click()
          cmbClass.listindex = 1
end sub

private sub optClass3_click()
          cmbClass.listindex = 2
end sub

Or something along those lines anyways.
Reply
#15
Perfekt Wrote:If you have a base set amount of classes, and you're not going to change it anytime soon, it's really simple.

Code:
private sub optClass1_click()
          cmbClass.listindex = 0
end sub

private sub optClass2_click()
          cmbClass.listindex = 1
end sub

private sub optClass3_click()
          cmbClass.listindex = 2
end sub

Or something along those lines anyways.
He has already said that lol
Reply
#16
I know he has. But he then said that he didn't think it would be hard. So I made that post.

Pay attention.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)