Skip to main content
gamedev.net
🔒 Locked

visual basic

Started by jedi2832 11 replies 1.3k views
Original Post
jedi2832
jedi2832
this topic fits here better ButtonConst = cboType(0) + cboType(1) + cboType(2) x = MsgBox("Prompt", ButtonConst, "Title") lets say i have vbokonly stored in cbotype0, vbquestion stored in 1 and vbdefaultbutton2 stored in 2, and i want to add them up and put it into buttonconst, and later display through msgbox, but that code doesnt work, how can i fix it, so the code funtions, and it will display the msgbox with default 2 button question with okonly msgbox if u can help, it is greatly appreciated
RomSteady
RomSteady
A couple of things:

1) If your message box is vbOKOnly, you only have one button, so the default button will not be the second button. The vbDefaultButton2 constant does not make it a two-button dialog, it tells it which button should be the default selection if the user hits Enter. Adding the vbDefaultButton2 flag doesn''t mean anything.

2) Are you storing the actual values of vbOKOnly, vbQuestion and vbDefaultButton2 in the combo box somewhere?

3) Ideally, you should be "Or"ing those flags together, not adding them.

RomSteady - I play games for a living.
Michael Russell / QA Manager, Ritual EntertainmentI used to play SimCity on a 1:1 scale.
jedi2832
jedi2832
well, i have 3 combo box, the first one store stuff like vbcancel, vbyesno, second one stores question,, vbcritical, third one stores vbdefaultbutton4 and stuff, if i do
x = ("agsd", vbYesNo+vbCritical, "dgd") it works, just now i want to add all 3 to buttonconst, so i just have huttonconst to display the msgbox
Nik02
Nik02
As RomSteady suggested, you should "OR" the flags together instead of adding them using "+". The flags contain bit values, and very likely will lose their meaning if you just add them together.

-Nik
Niko Suni
Basketball89
Basketball89
Have you even defined your variables.
Jakoozie
jedi2832
jedi2832
ButtonConst = cboType(0) Or cboType(1) Or cboType(2)
x = MsgBox("Prompt", ButtonConst, "Title")
this code still doesnt work, it says type mismatch, besides that, if the first line of code worked, i dont think that second line will work, if i assigned all that types of msgbox to buttonconst, and want it to show it, will it work? how do i make it work
jedi2832
jedi2832
just so u know, the cbotype are the combo boxes
Nik02
Nik02
Try
ButtonConst = CLng(cboType(0)) Or CLng(cboType(1)) Or CLng(cboType(2)).

EDIT: I just realized you're probably trying to use the combobox' text as the actual bitmasks. It won't work that way.
For example, vbYesNo actually is a constant number, and you can't just use the string "vbYesNo" in it's place.

[edited by - Nik02 on October 19, 2003 11:45:36 AM]
Niko Suni
jedi2832
jedi2832
still type mismatch, there must be a way to turn cbotype into stuff like vbokyesno
Nik02
Nik02
Use Select Case to solve this problem.



Dim cbo0flag as long 'other flag variables should also be declared.
Select Case cboType(0)
Case "vbYesNo": cbo0flag = vbYesNo
Case "whatever": cbo0flag = vbWhatEver


End Select
'repeat the select with each combobox.


MsgBox("test", cbo0flag Or cbo1flag Or cbo2flag, "title")


[edited by - Nik02 on October 19, 2003 11:55:21 AM]
Niko Suni
jedi2832
jedi2832
oh, so u cant use the text in the combo box u select, but how would i make it so, that people select what they want in the combo boxes, and when i click a button, it shows them the msgbox, and what u mean by using select case, i''m not so sure on how to do that, thx for helping
krez
krez
the "vbYesNoCancel" and such are INTEGERS, the text in the combo boxes are STRINGS. they are different data types.

as for the "how do i use select...case", either look it up in yourt documentation, or refer to the example given in the post above yours.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
jedi2832
jedi2832
it worked, u are a lifesaver, thx alot

yah, i posted first, but since he edited, didnt see his case statement, it worked now, thx Nik02

[edited by - jedi2832 on October 19, 2003 12:09:17 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.