Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,966 members, 7,806,800 topics. Date: Wednesday, 24 April 2024 at 12:46 AM

Abeg O,help Me With Dis VB.NET Code - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Abeg O,help Me With Dis VB.NET Code (1113 Views)

I Need A Help To Write A Simple Login Form Using Vb.net / Vb.net Code To Display Image In Picturebox From Sql Server / Post Ur Vb 6.0 Questions Here (2) (3) (4)

(1) (Reply) (Go Down)

Abeg O,help Me With Dis VB.NET Code by Lakulos(m): 9:17pm On Oct 13, 2012
I trying to write a program on a simple calculator using visual studio 2008,i want the user to be able to enter values in 2 textboxes and submit the result to a third textbox,the problem am encountering is that the program is not bringing out error and it is not also it is not calculating anything. This is my code.

Dim num1 as integer
Dim num2 as integer
Dim ans as integer
num1=val(textbox1.text)
num2=val(textbox2.text)
ans=val(textbox3.text)
ans=num1+num2.
Thanks.
Re: Abeg O,help Me With Dis VB.NET Code by mkwayisi: 8:16am On Oct 14, 2012
I'm a bit rusty with VB but from what I can see, everything works just that you're not showing the answer in textBox3. So perhaps you might want to do something like this:
textBox3.Text = ans
Re: Abeg O,help Me With Dis VB.NET Code by usisky(m): 8:17am On Oct 14, 2012

^^^^Your code should work, but....
Lakulos: I trying to write a program on a simple calculator using visual studio 2008,i want the user to be able to enter values in 2 textboxes and submit the result to a third textbox,the problem am encountering is that the program is not bringing out error and it is not also it is not calculating anything. This is my code.

0-Dim num1 as integer
1-Dim num2 as integer
2-Dim ans as integer
3-num1=val(textbox1.text)
4-num2=val(textbox2.text)
5-ans=val(textbox3.text)
6-ans=num1+num2.
Thanks.


@line5: what's this supposed to be doing? assigning unknown value of Textbox to Your result! code can't work!
@line6: correct! but where are you displaying this result? certainly not Textbox3.

anyway, change line5 to: ans = num1+num2, then line6 to: Textbox3.Text = ans. should work .

also,

Dim num1 As Integer = Integer.Parse(TxtNum1.Text)
Dim num2 As Integer = Integer.Parse(TxtNum2.Text)
TxtResult.Text = num1 + num2


Advice: If you're a newbie, or even a seasoned programmer for that matter; always get the logic of your intended program done on a paper before rushing to your editor....It reduces Your brain processing time.


Re: Abeg O,help Me With Dis VB.NET Code by Tamorion: 2:54pm On Oct 20, 2012
Lakulos: I trying to write a program on a simple calculator using visual studio 2008,i want the user to be able to enter values in 2 textboxes and submit the result to a third textbox,the problem am encountering is that the program is not bringing out error and it is not also it is not calculating anything. This is my code.

Dim num1 as integer
Dim num2 as integer
Dim ans as integer
num1=val(textbox1.text)
num2=val(textbox2.text)
ans=val(textbox3.text)
ans=num1+num2.
Thanks.
I think Mkwayisi has answered your question but just want to chip in a little.
The variable 'ans' has your value in memory but you have not asked your application to display the result.
You can do this a variety of ways including mkwayisi's suggestion (textbox3.text = ans). e.g

textbox3.text = val(textbox1.text) + val(textbox2.text) just to miniaturize your code. But this is sure NOT the best way to do it.

(1) (Reply)

Are Your Programmers Working Hard, Or Are They Lazy? / How To Get Started With Github / SMART CODE : Android Barcode Creator & Scanner

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.