Banking Program

Your Valued Opinion Needed Urgently

Page 1 of 1

4 Replies - 15152 Views - Last Post: 06 October 2010 - 03:41 PM Rate Topic: -----

#1 Nasieve   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-October 10

Banking Program

Posted 05 October 2010 - 10:48 AM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: Banking Program

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,004
  • Joined: 12-June 08

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'.

This post has been edited by modi123_1: 05 October 2010 - 11:19 AM

Was This Post Helpful? 0
  • +
  • -

#3 Guest_AHZ14*


Reputation:

Re: Banking Program

Posted 05 October 2010 - 01:19 PM

View Postmodi123_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'.

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
Was This Post Helpful? 0

#4 Nasieve   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-October 10

Re: Banking Program

Posted 06 October 2010 - 09:10 AM

thank you very much for your help you guys. i really appreciate it
Was This Post Helpful? 0
  • +
  • -

#5 guyfromri   User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 836
  • Joined: 16-September 09

Re: Banking Program

Posted 06 October 2010 - 03:41 PM

Try this

Deposit = Val(txtDeposit.Text) + Val(txtAccBal.Text)



in VBA -- Val will actually perceive the string as an integer
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1