Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I Have one text box in that if enter an value example like this

"99" then in second text box it should come as "9+9"=18 output

How can i implement this logic in visual basic form please help me
Posted

Hi,

First of all, you need to tag question properly to identify technology you are using.

As you stated in your question, it's VB project so you can use Key Up event of textbox to get value and process on it. hope you have idea how to write code to add 9+9 and set in the next text box.

best luck
 
Share this answer
 
Comments
[no name] 27-Dec-12 7:54am    
see sir iam developing in windows form application

i have two text boxes in first text box i enter "99" and in second text box the output should come as 9+9= "18" that means 18 should come as output in second text box please tell me code.......
AmitGajjar 27-Dec-12 8:02am    
No one will provide code here, you have to atleast try something and post your code.
[no name] 27-Dec-12 8:06am    
Same dialog i gave to one person@ one year ago
AmitGajjar 27-Dec-12 8:07am    
hmm, you know world is very small. your word come back to you again. i suggest you to read first 2-3 chapters of any VB.NET book
[no name] 27-Dec-12 8:12am    
Dim dt As Integer
Dim mt As Integer
Dim yr As Integer
Dim lpn As Integer

dt = TextBox4.Text
mt = TextBox5.Text
yr = TextBox6.Text

lpn = dt + mt + yr

TextBox7.text = Val(lpn)


this i tried but i don't know how to separate and add the values in same text box please help me
Since this sounds a LOT like you homework, I won't give you any code!

But it isn't difficult at all:

1) Create a "total" variable to hold the result. Set it to zero.
2) Loop though each character in the input string - a For Each loop will do that very easily.
2.1) Check if the character is a digit i.e. '0' to '9'
2.2) If it is, convert it to a numeric value, and add it to your total
2.3) If it isn't, either ignore it, or report the problem and exit the method - your choice.
3) After the loop, set the Text property of teh second text box to the total, using the ToString method.
 
Share this answer
 
Comments
[no name] 27-Dec-12 7:51am    
dear Griff,

This isn't my home home work and i am from India in India even in b.tech there in no visual basic concept and they won't home work

i have two text boxes in first text box i enter "99" in second text box the output should come as 9+9 = "18" .that means 18 should come as output.please tell me logic pleaseeeeeeeeeeeee
AmitGajjar 27-Dec-12 8:03am    
logic is already given in the solution, you just need to write code. so simple dear.
[no name] 27-Dec-12 8:14am    
Dim dt As Integer
Dim mt As Integer
Dim yr As Integer
Dim lpn As Integer

dt = TextBox4.Text
mt = TextBox5.Text
yr = TextBox6.Text

lpn = dt + mt + yr

TextBox7.text = Val(lpn)

i don't Know how to add the value in same text box please help me i don't understand your 1st answer please clearly specify!!!!!!
OriginalGriff 27-Dec-12 9:37am    
That is a different question to the one you originally asked, and needs a different answer.
Try:
Dim result As Integer = Integer.Parse(dt) + Integer.Parse(mt) + Integer.Parse(yr)
TextBox7.text = result.ToString()
OriginalGriff 27-Dec-12 8:06am    
It doesn't matter where you are from - a simple beginners problem is a simple beginners problem!

You have the logic you need - all you have to do is code it.
It is about one line of code per line of text in the logic, so it really, really isn't a complicated job. And you will learn a lot more doing it yourself, than by my writing it down for you! :laugh:
VB
Dim i As Integer = 0
For Each digit In (TextBox1.Text)
           i += Val(digit)
       Next
       TextBox2.Text = i.ToString
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900