|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Please help
im desgining a scientific calculator and its not completed as yet. at the moment my problem is it is working but say if i multiply 1 by one then i add one to the result and i press the equal button it will show as for. in other words if i change from one operation to another without pressing the equal button it will take the displayed value as if i have entered that value. please take a look at my code and show me some tips to fix it up thanks
Dim i As Integer Dim sofar As Integer Private Sub cmdadd_Click() 'If Not (i = 1) Then 'txtdis.Text = " " 'End If sofar = sofar + Val(txtdis.Text) txtdis.Text = " " lblsofar = (sofar) i = 1 End Sub Private Sub cmdclear_Click() txtdis.Text = " " sofar = 0 End Sub Private Sub cmddig_Click(Index As Integer) ' the digits from 0 to 9 Dim S As String Dim i As Integer S = txtdis.Text S = S & cmddig(Index).Caption txtdis.Text = S End Sub Private Sub cmdequal_Click() If i = 1 Then txtdis = Val(Val(txtdis) + Val(sofar)) End If If i = 2 Then 'x = MsgBox(i) txtdis = Val(Val(txtdis) * Val(sofar)) End If If i = 3 Then txtdis = Val(Val(sofar) - Val(txtdis)) End If If i = 4 Then txtdis = Val(Val(sofar) / Val(txtdis)) End If lblsofar = sofar End Sub Private Sub cmdmultiply_Click() 'If Not (i = 2) Then 'txtdis.Text = " " 'End If If sofar = 0 Then sofar = 1 End If sofar = (sofar) * Val(txtdis.Text) Me.Print (sofar) txtdis.Text = " " i = 2 lblsofar = sofar End Sub Private Sub cmdsubtract_Click() sofar = Val(txtdis.Text) - (sofar) Me.Print (sofar) txtdis.Text = " " i = 3 lblsofar = sofar End Sub Private Sub txtdivide_Click() If sofar = 0 Then sofar = 1 End If sofar = Val(Val(txtdis.Text) / (sofar)) x = MsgBox(sofar) txtdis.Text = " " i = 4 lblsofar = sofar End Sub |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Please help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|