Option Explicit
Sub macro()
Dim firstnumber As Single, secondnumber As Single, answernumber As Single, arithmeticprocess As String
firstnumber = Val(TextBox1.Text)
End Sub
Private Sub cmd0_Click()
TextBox1.Text = txtdisplay.Text & "0"
End Sub
Private Sub cmd1_Click()
TextBox1.Text = TextBox1.Text & "1"
End Sub
Private Sub cmd2_Click()
TextBox1.Text = TextBox1.Text & "2"
End Sub
Private Sub cmd3_Click()
TextBox1.Text = TextBox1.Text & "3"
End Sub
Private Sub cmd4_Click()
TextBox1.Text = TextBox1.Text & "4"
End Sub
Private Sub cmd5_Click()
TextBox1.Text = TextBox1.Text & "5"
End Sub
Private Sub cmd6_Click()
TextBox1.Text = TextBox1.Text & "6"
End Sub
Private Sub cmd7_Click()
TextBox1.Text = TextBox1.Text & "7"
End Sub
Private Sub cmd8_Click()
TextBox1.Text = TextBox1.Text & "8"
End Sub
Private Sub cmd9_Click()
TextBox1.Text = TextBox1.Text & "9"
End Sub
Private Sub cmddecmil_Click()
TextBox1.Text = TextBox1.Text & "."
End Sub
Private Sub cmddivide_Click()
firstnumber = Val(TextBox1.Text)
txtdisplay.Text = "0"
arithmeticprocess = "/"
End Sub
Private Sub cmdequals_Click()
secondnumber = Val(TextBox1.Text)
If arithmeticprocess = "+" Then
answernumber = firstnumber + secondnumber
End If
If arithmeticprocess = "-" Then
answernumber = firstnumber - secondnumber
End If
If arithmeticprocess = "*" Then
answernumber = firstnumber * secondnumber
End If
If arithmeticprocess = "/" Then
answernumber = firstnumber / secondnumber
End If
txtdisplay.Text = answernumber
End Sub
Private Sub cmdmalti_Click()
firstnumber = Val(TextBox1.Text)
txtdisplay.Text = "0"
arithmeticprocess = "*"
End Sub
Private Sub cmdminus_Click()
firstnumber = Val(TextBox1.Text)
txtdisplay.Text = "0"
arithmeticprocess = "-"
End Sub
Private Sub cmdplus_Click()
firstnumber = Val(TextBox1.Text)
txtdisplay.Text = "0"
arithmeticprocess = "+"
End Sub
Trying to build a Calculator Using Excel VBA.. Hope someone can help me debug it :)
Started by hikero1, Dec 12 2010 01:32 PM
1 reply to this topic
#1
Posted 12 December 2010 - 01:32 PM
|
|
|
#2
Posted 13 December 2010 - 03:03 PM
Hi hikero1,
It might be best if you post your code within the code tags because it makes it much easier to read. :)
Also, I'm not sure what you're asking for... Your code looks alright from what I can tell, but I don't know what your form design is so there's no way for me to replicate what you've created. If you want me to test it out (if you used VB 2010), you can compress your project folder without the Obj and Bin folders into a ZIP file format and attach it so I can take a look for you. :)
Bound
It might be best if you post your code within the code tags because it makes it much easier to read. :)
Also, I'm not sure what you're asking for... Your code looks alright from what I can tell, but I don't know what your form design is so there's no way for me to replicate what you've created. If you want me to test it out (if you used VB 2010), you can compress your project folder without the Obj and Bin folders into a ZIP file format and attach it so I can take a look for you. :)
Bound


Sign In
Create Account

Back to top









