Sending dropdown values to message box

Soumya1092

Commendable
May 24, 2016
2
0
1,510
I am using VB 2013 and trying to send values from a dropdown to a message box, but it's returning 0. My code is as below :

C++:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim value1 As String
        Dim value2 As String

        value1 = Val(Project_Name.SelectedItem)
        value2 = Val(ComboBox2.SelectedItem)
        Windows.Forms.MessageBox.Show(value1, value2)

    End Sub

Where have I gone wrong? Appreciate any help / suggestion. I am completely new to Vb.net
 

Soumya1092

Commendable
May 24, 2016
2
0
1,510
You can use String.Format like :

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim value1 As String
Dim value2 As String
value1 = Project_Name.SelectedItem.ToString()
value2 = ComboBox2.SelectedItem.ToString()
Dim s As String = String.Format("Value 1: {0} value2 : {1}", value1 , value2)
Windows.Forms.MessageBox.Show(s)

End Sub