|
-
Sep 4th, 2002, 02:25 PM
#1
Thread Starter
New Member
Help with vb.net
sorry if this is a really dumb question, but my school just got microsoft visual studio .NET and no one nows how to work it, my main question is why this code doesn't work
dim x as integer
dim y as integer
x = txtX
y = txtY
lblsum = x + y
It blue underlines everything after the equal signs and when I try to run it it says for the first two erros "value of type 'System.Form.TextBox' cannot be converted to Integer"
the third error is "value Integer cannot be converted to 'System.Windows.Form.label'
thanks for any answers
-
Sep 4th, 2002, 02:46 PM
#2
Lively Member
In vb.net unlike vb6 you cant just put txtX. You have to use txtX.Text.
Also youve declared x and y as integers but txtX.Text is a string. You would have to convert it to an integer first.
Again for the label you have to use lblsum.Text and you have to convert it to a string first.
I'm new to this too but I think this is right
-
Sep 4th, 2002, 03:17 PM
#3
Frenzied Member
This is what you need to do. When you are trying to get integer values from textboxes, you need to parse it first. So you would do this:
VB Code:
Dim x as integer
Dim y as integer
Dim total as integer
x = integer.Parse(txtX.text)
y = integer.Parse(txtY.text)
total = x + y
lblsum.Text = total.ToString()
Hope that helps
Dont gain the world and lose your soul
-
Sep 4th, 2002, 05:25 PM
#4
Thread Starter
New Member
thanks for the Help and vb.net is really confusing
-
Sep 4th, 2002, 06:05 PM
#5
Junior Member
Its only confusing because it does not hold your hand quite as much as VB6.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|