Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 132,685 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,253 people online right now. Registration is fast and FREE... Join Now!




simple question on my coding

 
Reply to this topicStart new topic

simple question on my coding, i forgot a lot of things help me out

Henishi
post 4 Sep, 2008 - 02:07 PM
Post #1


D.I.C Head

**
Joined: 15 Jun, 2008
Posts: 50


My Contributions


simple question i makin a simple calculator but i think im forgeting something here i added 2 text box wich they are gonna be where i input the numbers to add , a button to sum and a label for the question

I made this on the button the code
Dim Sum As Integer
Sum = Val(TextBox1) + Val(TextBox2)

but i dont know how to make it show on the label box i think im doin somethin wrong i tried doin

Label1=Sum


but that doesnt work any one that can help me out ?
User is offlineProfile CardPM

Go to the top of the page

Reverand Dave
post 4 Sep, 2008 - 02:33 PM
Post #2


D.I.C Regular

Group Icon
Joined: 27 Jul, 2008
Posts: 373



Thanked 2 times

Dream Kudos: 50
My Contributions


You'll want to do something like this:

CODE

Dim Sum as Integer

Sum = (Textbox1.value) + (Textbox2.value)

label1.caption = sum


The default value for labels is the .caption value and the default values for textboxes is .value. This is for VBA. For VB6, the default value for text boxes is .text.
User is offlineProfile CardPM

Go to the top of the page

Henishi
post 4 Sep, 2008 - 02:53 PM
Post #3


D.I.C Head

**
Joined: 15 Jun, 2008
Posts: 50


My Contributions


QUOTE(Reverand Dave @ 4 Sep, 2008 - 03:33 PM) *

You'll want to do something like this:

CODE

Dim Sum as Integer

Sum = (Textbox1.value) + (Textbox2.value)

label1.caption = sum


The default value for labels is the .caption value and the default values for textboxes is .value. This is for VBA. For VB6, the default value for text boxes is .text.



Im using visual studio 2008 its the same stuff right ?
User is offlineProfile CardPM

Go to the top of the page

Reverand Dave
post 4 Sep, 2008 - 02:55 PM
Post #4


D.I.C Regular

Group Icon
Joined: 27 Jul, 2008
Posts: 373



Thanked 2 times

Dream Kudos: 50
My Contributions


VS2008 is VB.NET so I'm not sure if the same syntax will work, but it should.
User is offlineProfile CardPM

Go to the top of the page

Henishi
post 4 Sep, 2008 - 02:58 PM
Post #5


D.I.C Head

**
Joined: 15 Jun, 2008
Posts: 50


My Contributions


doesnt work :S
User is offlineProfile CardPM

Go to the top of the page

dineeshd
post 5 Sep, 2008 - 01:51 AM
Post #6


D.I.C Addict

Group Icon
Joined: 30 Jun, 2008
Posts: 561



Thanked 16 times

Dream Kudos: 575
My Contributions


Try this for VB.Net....

vb
Dim Value1 As Integer
Dim Value2 As Integer

Value1 = TextBox1.Text
Value2 = TextBox2.Text

Label1.Text = Value1 + Value2
User is offlineProfile CardPM

Go to the top of the page

aneeshd
post 5 Sep, 2008 - 02:05 AM
Post #7


New D.I.C Head

*
Joined: 24 Aug, 2008
Posts: 12


My Contributions



VB.Net

CODE


Label1.Text = Val(TextBox1.Text) + Val(TextBox1.Text)

User is offlineProfile CardPM

Go to the top of the page

dineeshd
post 5 Sep, 2008 - 02:18 AM
Post #8


D.I.C Addict

Group Icon
Joined: 30 Jun, 2008
Posts: 561



Thanked 16 times

Dream Kudos: 575
My Contributions


QUOTE(aneeshd @ 5 Sep, 2008 - 03:35 PM) *

VB.Net
CODE
Label1.Text = Val(TextBox1.Text) + Val(TextBox1.Text)


That makes more sense. In my code if we are not entering any value it will throw error.

Good thinking aneeshd
User is offlineProfile CardPM

Go to the top of the page

Reverand Dave
post 5 Sep, 2008 - 04:54 AM
Post #9


D.I.C Regular

Group Icon
Joined: 27 Jul, 2008
Posts: 373



Thanked 2 times

Dream Kudos: 50
My Contributions


Can a mod move this to the VB.NET forum.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 07:13AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month