|
First problem is you're reading outdated tutorials that tell you about VB 6, but you're working in VB.NET.
In the first example, you've got some integer variables that you're using to describe a rectangle in primitive terms ... and you have three textbox variables representing user interface elements on your window or page. Obviously, these two kinds of variables are very different. In your second example, I would think your code just wouldn't compile, but that's odd. Anyway, you can't just replace the user interface elements where people tell you some data with integers to hold that data.
Try:
Public Class Form1
Private Sub cmdCalculate_Click()
Dim rec1 As Integer
Dim rec2 As Integer
Dim rec3 As Integer
rec1 = int.Parse(txtLength.Text)
rec2 = cInt(txtWidth.Text)
rec3 = rec1 * rec2
textArea.Text = rec3
End Sub
End Class
You can use int.Parse or cInt ... they'll ultimately have the same effect. Which is to turn "17" into just 17, but to throw an exception if you try to convert "seventeen" into a number. It's a matter of preference ... cType is a VB only set of functions, whereas type.Parse extends across the framework.
You have a variable pointing at the text boxes; you need it's .Text property to get what someone typed into it. You could use its other properties to calculate its width, to move it, enable or disable it, etc.
|