Good Day!.
Im, a new programmer.
I want that the value of my textbox6 in form1 will add to the value of the textbox6 in form2. can anyone help me. :(

Recommended Answers

All 7 Replies

What do you mean by "Value"?
Are you concatenating strings or adding numbers?
If you are adding numbers, have you converted the form2.textbox6.Text to a numeric value?

If you mean string + string, did you?: form1.textbox6.Text += form2.textbox6.Text;

well bernardz26! there are two simple ways to perform this , one is to declare a global or public variable and just access it at any part of your prog , and second way is to call the form then the call the control , here are both ways to perform this operation ,

'declare the public variable
public mynumber as int
 'now assign the value of first textbox of form1 to it .
'use this at the text change event of the textbox
mynumber = val(textbox6.text)
'now place this code at the your form two at any event where you want to sum both values of textbox6 of form1 and textbox6 of form2
textboxResult.text = val(textbox6.text)+mynumber
'this will show the result and sum both textbox values

now there is another way to perform same operation .

'use this code where you want to sum both values
textboxResult.text= val(form1.textbox6.text)+val(textbox6.text)

this will also perform same operation , hope this will solve your prob ,if your prob is solve then please dont forget to mark this thread solve ,

Regards

well bernardz26! there are two simple ways to perform this , one is to declare a global or public variable and just access it at any part of your prog , and second way is to call the form then the call the control , here are both ways to perform this operation ,

'declare the public variable
public mynumber as int
 'now assign the value of first textbox of form1 to it .
'use this at the text change event of the textbox
mynumber = val(textbox6.text)
'now place this code at the your form two at any event where you want to sum both values of textbox6 of form1 and textbox6 of form2
textboxResult.text = val(textbox6.text)+mynumber
'this will show the result and sum both textbox values

now there is another way to perform same operation .

'use this code where you want to sum both values
textboxResult.text= val(form1.textbox6.text)+val(textbox6.text)

this will also perform same operation , hope this will solve your prob ,if your prob is solve then please dont forget to mark this thread solve ,

Regards

we can also use the CInt instead of Val or the Integer.Parse method

commented: Right. Val is vb6 function. +14

try this

textbox1.text = val(form1.textbox6.text) + val(textbox6.text)

put this code in an onclick event,, this will add the value of text6 from form1 and text6 from form2 and it will display its answer on the text1

Form2.TextBox6.Text = Form2.TextBox6.Text & Form1.TextBox6.Text

LOL

...You could also make a function to do this.

...I saw the horses head move and decided to continue the beating.

1. Do not create controls public - keep them private.
2. Use form1`s reference on form2, so you can access memebers of form1 from form2.

Then simply use this reference on form2 to get the value (you want to) from form1.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.