|
-
Dec 30th, 2000, 04:07 PM
#1
Güten abends.
I could use some help on how to define a value for a ListBox choice. I've started making a little program called Message Maker, where I construct Windows dialouges.
some example code:
MsgBox txtMessage, ,txtTitle
As you can see I got the values I need for the Title and the message, but I still need to know how too get a value out of a listbox and putting it in there between the commas.
For example I have a value in a listbox called "OK", I want that value type in vbOkOnly between the commas.
Does anybody know how to? BTW, is there any good beginners forums around?
-
Dec 30th, 2000, 04:40 PM
#2
Hey!
Guys (and girls), I really need to know how to do this, and it's quite urgent.. Maybe I should refraze the question a little
I need to know how to make ListBox choice to put in the string = vbOkOnly in a line of code. I want it to look like this:
Code:
MsgBox "Message", vbOkOnly,"Title"
Please reply, even if you don't know what the heck you're talking about, reply anyway.
-
Dec 30th, 2000, 05:15 PM
#3
Member
from what i understood, a think this is what you need:
Code:
Private Sub Command1_Click()
If List1.Text = "vbOkOnly" Then
MsgBox "message", vbOKOnly, "Title"
Else
If List1.Text = "VbYesNo" Then
MsgBox "Message", vbYesNo, "title"
'etc........
End If
End If
End Sub
VP/Sonic taking on the (vb) world, one post at a time.
-
Dec 30th, 2000, 05:27 PM
#4
Danke schön
Thanks for the tip, there's gonna be alot o Ifs, do you think I can do it with the Select Case thingie? I'll just go ahead and try it.
-
Dec 30th, 2000, 07:56 PM
#5
Frenzied Member
Sure, why not? 
Code:
Select Case List1.Text
Case "vbOkOnly"
MsgBox "message", vbOKOnly, "Title"
Case "VbYesNo"
MsgBox "Message", vbYesNo, "title"
End Select
A tip for Visual Programmer:
ElseIf
Code:
Private Sub Command1_Click()
If List1.Text = "vbOkOnly" Then
MsgBox "message", vbOKOnly, "Title"
ElseIf List1.Text = "VbYesNo" Then
MsgBox "Message", vbYesNo, "title"
'etc........
End If
End Sub
Have fun both of you 
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Dec 30th, 2000, 08:04 PM
#6
Actually, you don't need to test with Ifs or Select Case. Whatever the user selected in the listbox can be read with the Listbox's Text property (or with the List array property). In other words, you can reference the user's selection either as
List1.Text
- or -
List1.List(List1.ListIndex)
So your code can be;
Code:
MsgBox "message", List1.Text, "Title"
"It's cold gin time again ..."
Check out my website here.
-
Dec 31st, 2000, 04:12 PM
#7
Hello,
Try this code in the ListBox click event:
Select Case lst1.ListIndex
Case 0
MsgBox "message", vbOKOnly, "Title"
Case 1
MsgBox "message", vbOKCancel, "Title"
End Select
End Sub
Use the AddItem method in the FormLoad event to fill
the ListBox with vbOKOnly,vbOKCancel, etc. Then just
click on the one you want to use.
Good luck
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|