4 Replies - 590 Views - Last Post: 02 October 2012 - 05:26 AM Rate Topic: -----

#1 laklaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 01-October 12

Problem using array.

Posted 01 October 2012 - 08:37 PM

Hello everyone! Thank you for having a view on my thread. So here is my problem. I'm having a problem with an array. I'm creating an ATM (A school project). I have a 5 form and 1 module I use to code in the module now here's the problem.
Dim num As Integer, check As Integer, pin_number As Integer, withdraw_kana As Integer, withdraw_total As Integer, deposit_kana As Integer, deposit_total As Integer
Dim username(5) As String
Dim balance(5) As Integer
Public Sub Login()
username(0) = "167669123"
username(1) = "742141189"
username(2) = "968431187"
username(3) = "167669123"
username(4) = "677418873"
check = 0
For num = 0 To 4
If (Login_Form.pin_txt = username(num)) Then
pin_number = num
Menu_Form.Show
Login_Form.Hide
Else
check = check + 1
If (check = 3) Then
check = 1
End If
End If
Next
If (check = 1) Then
MsgBox "Incorrect Login"
Login_Form.Form_Load
End If
End Sub

Public Sub pin_quiry()
Balance_Form.lblBalance.Caption = balance(pin_number)
End Sub


Public Sub withdraw_click()
withdraw_kana = Withdraw_Form.txtCheckBalance.Text
balance(pin_number) = balance(pin_number) - withdraw_kana
If (withdraw_total <= 0) Then
MsgBox "Sorry but you can't withdraw because of insuffecient balance"
Else
MsgBox "You've successfully withdraw a money (Kempet)"
End If
End Sub

Public Sub deposit()
Deposit_Form.lblCheckBalance.Caption = balance(pin_number)
End Sub

Public Sub deposit_click()
deposit_kana = Deposit_Form.txtDeposit.Text
balance(pin_number) = balance(pin_number) + deposit_kana
MsgBox "You've successfully deposited a money (Daw)"
Deposit_Form.lblCheckBalance.Caption = balance(pin_number)
End Sub

Public Sub withdraw()
Withdraw_Form.lblCheckBalance.Caption = balance(pin_number)
End Sub



Everytime I go to the withdraw form it doesn't show the new pin number. :s. Hope that you can help me and thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Problem using array.

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: Problem using array.

Posted 02 October 2012 - 12:09 AM

Is this all the code you have?

Could you please highlight the line where you get the problem.

It's early morning here and maybe I'm not awake yet, but I'm struggling following your code....
Was This Post Helpful? 0
  • +
  • -

#3 laklaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 01-October 12

Re: Problem using array.

Posted 02 October 2012 - 04:44 AM

This part

Public Sub deposit()
Deposit_Form.lblCheckBalance.Caption = balance(pin_number)
End Sub

Public Sub withdraw()
Withdraw_Form.lblCheckBalance.Caption = balance(pin_number)
End Sub



It doesn't show the new balance everytime I entered a new deposit.
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: Problem using array.

Posted 02 October 2012 - 04:57 AM

Where do you call these functions?

I don't see any calls to them in your posted code?
Was This Post Helpful? 0
  • +
  • -

#5 laklaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 01-October 12

Re: Problem using array.

Posted 02 October 2012 - 05:26 AM

View Postmaj3091, on 02 October 2012 - 04:57 AM, said:

Where do you call these functions?

I don't see any calls to them in your posted code?


Do I need to call it? It's on the 1 module then I don't know how to call. :s.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1