d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > How To Rewrite The Msgbox? > Vba
Add Reply New Topic New Poll
Member
Posts: 432
Joined: Jul 29 2016
Gold: 0.00
Aug 11 2016 03:26pm
Is there any way I can rewrite the message box? I don't want to use Me.States.Value.

Private Sub UserForm_Initialize()

With States
.AddItem "Illinois"
.AddItem "Indiana"
.AddItem "Iowa"
.AddItem "Michigan"
.AddItem "Minnesota"
.AddItem "Ohio"
.AddItem "Pennsylvania"
.AddItem "Wisconsin"
.Value = "Indiana"
End With

End Sub

Private Sub ok_Click()
MsgBox ("You live in " & Me.States.Value)
End Sub
Member
Posts: 29,548
Joined: Mar 27 2008
Gold: 504.69
Warn: 10%
Aug 11 2016 04:32pm
Why don't you want to reference the combo box?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 11 2016 09:40pm
why don't you wanna use value?

but to answer your question, i looked up the members: https://msdn.microsoft.com/en-us/library/office/ff834728.aspx

looks like you can use ListIndex to get the index of the selected item and find it that way. A worse way is probably to use the text property and compare it with your items.
Go Back To Homework Help Topic List
Add Reply New Topic New Poll