Good morning everyone,
I'm new with VB 2008, and i've read a lot...
I'm trying to do a simple code, calculating 2 values with a function and showing in a third textbox.
Here it comes the code:
Private Sub btnvalor1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvalor1.Click
Dim valor1, valor2 As Integer
Dim maior As Integer
valor1 = CInt(TextBox1.Text)
valor2 = CInt(TextBox2.Text)
maior = vermaior(valor1, valor2)
maior = CInt(TextBox3.Text)
TextBox3.Text = maior
End Sub
Function vermaior(ByVal val1, ByVal val2)
If val1 > val2 Then
vermaior = val1
Else
vermaior = val2
End If
End Function
The problem is that when i run the code a error appears and close the program: Conversion from string "" to type 'Integer' is not valid.
The problem is in the textbox3
Can u tell me why do i need to put textbox.text?
thankss!!
I'm new with VB 2008, and i've read a lot...
I'm trying to do a simple code, calculating 2 values with a function and showing in a third textbox.
Here it comes the code:
Private Sub btnvalor1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvalor1.Click
Dim valor1, valor2 As Integer
Dim maior As Integer
valor1 = CInt(TextBox1.Text)
valor2 = CInt(TextBox2.Text)
maior = vermaior(valor1, valor2)
maior = CInt(TextBox3.Text)
TextBox3.Text = maior
End Sub
Function vermaior(ByVal val1, ByVal val2)
If val1 > val2 Then
vermaior = val1
Else
vermaior = val2
End If
End Function
The problem is that when i run the code a error appears and close the program: Conversion from string "" to type 'Integer' is not valid.
The problem is in the textbox3
Can u tell me why do i need to put textbox.text?
thankss!!