DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Simple Array Calculator Help

  1. #1
    Join Date
    Feb 2007
    Posts
    11

    Simple Array Calculator Help

    I need some help on this program that i have. i can't seem to get it to work.
    any comment on the program would be appreciated.
    Thx in advance.
    I have uploaded my program in case u need to take a look.

    Code:
    Dim first As Double
    Dim second As Double
    Dim sign As String
    
    Private Sub lbldot_Click()
         If InStr(txtdisplay.Text, ".") = 0 Then
              txtdisplay.Text = txtdisplay.Text & "."
         End If
    End Sub
    
    Private Sub lblnumber_Click(Index As Integer)
         If txtdisplay.Text = "" Then
         txtdisplay.Text = lblnumber(Index).Caption
         Else
              txtdisplay.Text = txtdisplay.Text & lblnumber(Index).Caption
         End If
    End Sub
    
    Private Sub lblsign_Click(Index As Integer)
         first = txtdisplay.Text
         txtdisplay.Text = ""
         sign = lblsign(Index).Caption
    End Sub
    Private Sub cmdEq_Click()
         txtdisplay.Text = second
         sign = lblsign(Index).Caption
         If sign = "-" Then
              txtdisplay.Text = first - second
         ElseIf sign = "+" Then
              txtdisplay.Text = first + second
         ElseIf sign = "*" Then
              txtdisplay.Text = first * second
         ElseIf sign = "/" Then
              txtdisplay.Text = first / second
         End If
    End Sub
    Private Sub cmdClear_Click()
        txtdisplay.Text = ""
    End Sub
    Private Sub cmdDot_Click()
         If InStr(txtdisplay.Text, ".") = 0 Then
              txtdisplay.Text = txtdisplay.Text & "."
         End If
    End Sub
    Private Sub Form_Load()
    txtdisplay.Enabled = False
    End Sub
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Can you be more specific? What problem(s) are you having?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Feb 2007
    Posts
    11
    Whenever i press the equal sign, the display text box alwasys shows "0".

  4. #4
    Join Date
    Feb 2007
    Posts
    11
    and also the button for equal sign(cmdeq) is not working properly. it doesnt add or subtract or divide or mutiply.

  5. #5
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    change

    Private Sub cmdEq_Click()
    txtdisplay.Text = second

    into

    Private Sub cmdEq_Click()
    second = txtDisplay.txt
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Similar Threads

  1. Reversing an Array
    By Tmcclain in forum Java
    Replies: 7
    Last Post: 02-13-2009, 11:57 PM
  2. Another Simple Array Question?
    By mp_direct in forum VB Classic
    Replies: 2
    Last Post: 12-14-2005, 01:07 PM
  3. Simple Array Question?
    By mp_direct in forum VB Classic
    Replies: 6
    Last Post: 11-23-2005, 03:28 PM
  4. Dynamically allocating a 2d array
    By nnp in forum C++
    Replies: 6
    Last Post: 11-01-2005, 10:05 AM
  5. Simple? Char array to string
    By Greg Brunet in forum .NET
    Replies: 1
    Last Post: 07-26-2002, 04:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center