Reputation: 3
I want to display a msgbox that contains information provided by a combo box. Specifically, if the combo box contains "Warning" I want the msgbox to display the warning icon.
Basically I need to know how to put the input from the combo box into the msgbox without having to make it have MsgBoxStyle.Critical
or something like that.
What I thought would work:
Private Sub Button1_Click(ByVal sender As system.object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.SelectedItem = "Warning" Then
ComboOutput = Msgboxstyle.critical
Hopefully my question is clear.
Upvotes: 0
Views: 201
Reputation: 4506
The following should work:
We load all the enum values on form load. Then on click we parse the name and display the message box.
Private Sub Form5_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ComboBox1.DataSource = [Enum].GetNames(GetType(MessageBoxIcon))
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim value = [Enum].Parse(GetType(MessageBoxIcon), CStr(ComboBox1.SelectedItem))
MessageBox.Show("Text", "Caption", MessageBoxButtons.OK, CType(value, MessageBoxIcon))
End Sub
Upvotes: 1