Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 18th, 2005, 06:58 AM
Registered User
 
Join Date: Mar 2005
Location: chennai, tamilnadu, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beginning VB6.0 Small Problem

Hello,

Here i used VB6.0 write one calculator program.

Here is the program what i did..

Option Explicit
Dim pv As Single
Dim a As Integer
Dim op As String
Dim m As Integer
Dim button As String
Private Sub cmdope_Click(Index As Integer)
pv = Val(Text1.Text)
Select Case Index
       Case 0
          op = "+"
       Case 1
          op = "-"
       Case 2
          op = "*"
       Case 3
          op = "/"

End Select
Text1.Text = " "

End Sub
Private Sub cmdnum_Click(Index As Integer)
Text1.Text = Text1.Text + cmdnum(Index).Caption

End Sub
Private Sub cmdequal_Click()
Select Case op
       Case "+"
          Text1.Text = pv + Text1.Text
       Case "-"
          Text1.Text = pv - Text1.Text
       Case "*"
          Text1.Text = pv * Text1.Text
       Case "/"
          Text1.Text = pv / Text1.Text

End Select
Text1.Text = Round(Text1.Text, 2)
End Sub
Private Sub cmdcancel_Click()
Text1.Text = " "
End Sub
Private Sub cmdmem_Click()
m = Val(Text1.Text)
Text1.Text = " "

End Sub
Private Sub cmdmrecall_Click()
Text1.Text = m
End Sub




Its working,but i couldn't get minus value
1) that is -22+2=-20 i can't get this...
what should i do??
2)I can't add any no with memory variable..




kalai
Reply With Quote
  #2 (permalink)  
Old April 10th, 2005, 11:06 AM
Authorized User
 
Join Date: Apr 2005
Location: Johannesburg, , South Africa.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Check if value given is smaller than 0.

Thus 1:
If its first value use beginning operator of "-" to indicate it's smaller than null

else, it its not first number punched, check for - operator preceding previous operator
Thus user will type 20 + -10 now you know you've got to operators a + and a - and now you know that it should be <0 value

Helga Anagnostopoulos
Reply With Quote
  #3 (permalink)  
Old April 11th, 2005, 01:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Add a +/- (change sign) button, and in its click event:

on error goto errsub
dim val as double
val = text1.text
text1.text=-val
exit syb
errsub:
msgbox err.description

and click the buttons in this sequence:

2
2
+/-
+
2
=

This is how a traditional calculator works.
Marco
Reply With Quote
  #4 (permalink)  
Old April 11th, 2005, 01:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

wait a minute: I already answered to the same post in another group:

http://p2p.wrox.com/topic.asp?TOPIC_ID=27741

this is why it sounded familiar...
dear Kalai,
please do not post the same post in multiple forum of the same group, and give your posts a more clear title. Everyone posts because has a problem...
Marco
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
small problem with cookies Paula222 ASP.NET 2.0 Professional 0 May 25th, 2007 02:08 AM
small problem with cookies Paula222 ASP.NET 2.0 Basics 0 May 25th, 2007 02:05 AM
Small problem VB (thanks!) kris5 VB How-To 2 November 27th, 2006 12:11 PM
How to upload small text file from within my vb6 f method Beginning VB 6 1 April 19th, 2006 01:17 PM
small problem harjinder_x XSLT 0 March 23rd, 2004 05:43 AM



All times are GMT -4. The time now is 12:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.