Mirage Source
Use OptionButton instead of ComboBox - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: Use OptionButton instead of ComboBox (/showthread.php?tid=1432)



Use OptionButton instead of ComboBox - Kay-No - 03-12-2007

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



Re: Use OptionButton instead of ComboBox - Anthony - 03-12-2007

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.


Re: Use OptionButton instead of ComboBox - Kay-No - 03-12-2007

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.


Re: Use OptionButton instead of ComboBox - Matt - 03-12-2007

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.


Re: Use OptionButton instead of ComboBox - Anthony - 03-12-2007

Oh right Big Grin I got confused between pictures and option buttons haha.


Re: Use OptionButton instead of ComboBox - Kay-No - 03-12-2007

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


Re: Use OptionButton instead of ComboBox - Beres - 03-12-2007

yeah thats right Tongue


Re: Use OptionButton instead of ComboBox - Kay-No - 03-12-2007

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



Re: Use OptionButton instead of ComboBox - Beres - 03-12-2007

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.


Re: Use OptionButton instead of ComboBox - William - 03-12-2007

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.


Re: Use OptionButton instead of ComboBox - Beres - 03-12-2007

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..


Re: Use OptionButton instead of ComboBox - Kay-No - 04-12-2007

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?


Re: Use OptionButton instead of ComboBox - William - 04-12-2007

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.


Re: Use OptionButton instead of ComboBox - Matt - 04-12-2007

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.


Re: Use OptionButton instead of ComboBox - Beres - 04-12-2007

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


Re: Use OptionButton instead of ComboBox - Matt - 04-12-2007

I know he has. But he then said that he didn't think it would be hard. So I made that post.

Pay attention.