hey my esteemed programmers i am seeking your help on a banking program i'm making for a school project in Visual Basics i cant use the deposit function whenever i use this code
Dim Deposit As Double If txtDeposit.Text = "" Then MsgBox "Add Amount for Transaction", vbInformation txtDeposit.SetFocus End If Deposit = txtDeposit.Text + txtAccBal.Text txtAccBal.Text = Deposit txtDeposit.Text = ""
it wont make the necessary additions to the existing value, say there was 80,000 in the account and i want to deposit 2000$ what it does when i press deposit it give me this 800002000 please help me THANKS MUCH IN ADVANCE
If any changes are needed to be made please advise me as soon as possible. And please forgive my lateness in requesting your help i only learned of this website today.
Banking ProgramYour Valued Opinion Needed Urgently
Page 1 of 1
4 Replies - 15152 Views - Last Post: 06 October 2010 - 03:41 PM
Replies To: Banking Program
#2
Re: Banking Program
Posted 05 October 2010 - 11:17 AM
It is because the "+", when dealing with strings, is a form of concatenation (appending the "right" string to the end of the "left" one). If you want to do actual math addition you need to convert those strings to integers or decimals. Probably decimals since you are dealing with money.
Conversion info:
http://msdn.microsof...y/s2dy91zy.aspx
Whoops - that's for .NET. Regardless check out your book for 'type conversion'.
Whoops - that's for .NET. Regardless check out your book for 'type conversion'.
This post has been edited by modi123_1: 05 October 2010 - 11:19 AM
#3 Guest_AHZ14*
Re: Banking Program
Posted 05 October 2010 - 01:19 PM
modi123_1, on 05 October 2010 - 10:17 AM, said:
It is because the "+", when dealing with strings, is a form of concatenation (appending the "right" string to the end of the "left" one). If you want to do actual math addition you need to convert those strings to integers or decimals. Probably decimals since you are dealing with money.
Conversion info:
http://msdn.microsof...y/s2dy91zy.aspx
Whoops - that's for .NET. Regardless check out your book for 'type conversion'.
Whoops - that's for .NET. Regardless check out your book for 'type conversion'.
hy, i can help you with tshi code
BUTTON1_click... :
textbox3.text = val(textbox1.text) + val(textbox2.text)
example : textbox1 = 200 / textbox2 = 300
textbox3.text = 200 + 300
textbox3.text = 500
#4
Re: Banking Program
Posted 06 October 2010 - 09:10 AM
thank you very much for your help you guys. i really appreciate it
#5
Re: Banking Program
Posted 06 October 2010 - 03:41 PM
Try this
in VBA -- Val will actually perceive the string as an integer
Deposit = Val(txtDeposit.Text) + Val(txtAccBal.Text)
in VBA -- Val will actually perceive the string as an integer
Page 1 of 1