Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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
 
Old March 10th, 2005, 04:07 AM
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default VisualBasic6.0

Hai,

    I have created one calculator program in Visual Basic 6.0.I have one doubt in this.please help me
My calculator program is working,but i want to add more in this.(i.e.,)
I'll explain what i did?
  I have created binary array for operators(+,-,*,/) and create another array for numbers(0-9)
Herewith i have attached my program...pls check it out ..and clarify my doubts..
__________________________________________________ __________________________________
Option Explicit
Dim pv As Single
Dim a As Integer
Dim op As String
Dim m As Integer

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


Private Sub Form_Load()
Form1.Show
End Sub
__________________________________________________ _____________________________________

1)I want to add any number with Negative number means what to do?? (i.e.,)-> -22+2=-20
How to do this?..

2)How to apply keypress event in this?

3)I can't retreive the memory value..Whenever i clicked the memrecall button only i can add any
number with that mem value..what i do??

Please send me the coding for all my doubts..

Eagerly Waiting for all Ur Reply..

ksvjb.
 
Old March 23rd, 2005, 07:19 AM
Authorized User
 
Join Date: Jan 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JelfMaria
Default

-22+2=-20

this is correct in vb6.the right answer is always displayed



 
Old March 23rd, 2005, 04:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Add a "Change Sign" button...

cmdChangeSign_Click()
text1.text = -val(text1.text)

Marco









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