Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 29th, 2003, 02:46 AM
TENEX TENEX is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: ...
Posts: 2 TENEX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Please help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT