answersLogoWhite

0

In visual basic 6.0:

Public input1, input2, number1, output, decimal2, operand, input3 As Double

Public operand2, oprand3 As String

Public decimal3 As Boolean

'Input

Private Sub Command1_Click(Index As Integer)

number1 = number1 + 1

'input1 decimal

If operand = 0 And decimal3 = True Then

number2 = 1 * (10 ^ (number1 - 1))

decimal2 = Index / number2

input1 = input1 + decimal2

Text1.Text = input1

End If

' input2 decimal

If operand > 0 And decimal3 = True Then

number2 = (1 * (10 ^ (number1 - 1)))

decimal2 = Index / number2

input2 = input2 + decimal2

Text1.Text = input1 & " " & operand2 & " " & input2

End If

'input1 single digits

If number1 < 2 And operand < 1 And decimal3 = False Then

input1 = Index

Text1.Text = input1

End If

' input1 multiple digits

If number1 > 1 And operand < 1 And decimal3 = False Then

input1 = (input1 * 10) + Index

Text1.Text = input1

End If

'input2 single digit

If operand > 0 And number1 < 2 And decimal3 = False Then

input2 = Index

Text1.Text = input1 & operand2 & input2

End If

'input2 multiple digits

If number1 > 1 And operand > 0 And decimal3 = False Then

input2 = (input2 * 10) + Index

Text1.Text = input1 & operand2 & input2

End If

End Sub

' Plus/Minus

Private Sub Command2_Click()

If operand < 1 Then

input1 = -1 * input1

Text1.Text = input1

End If

If operand > 1 Then

input2 = -1 * input2

Text1.Text = input1 & " " & operand2 & " ( " & input2 & " ) "

End If

End Sub

' Equals

Private Sub Command3_Click()

Select Case operand

Case Is = 1

output = input1 + input2

Text1.Text = input1 & operand2 & input2 & "=" & output

Case Is = 2

output = input1 - input2

Text1.Text = input1 & operand2 & input2 & "=" & output

Case Is = 3

output = input1 / input2

Text1.Text = input1 & operand2 & input2 & "=" & output

Case Is = 4

output = input1 * input2

Text1.Text = input1 & operand2 & input2 & "= " & output

End Select

input3 = output

number1 = 0

input1 = 0

input2 = 0

output = 0

operand = 0

number2 = 0

decimal2 = 0

decimal3 = False

End Sub

'Plus

Private Sub Command4_Click()

operand = 1

operand2 = "+"

Text1.Text = input1 & operand2

number1 = 0

number2 = 0

decimal3 = False

End Sub

'Minus

Private Sub Command5_Click()

operand = 2

operand2 = "-"

Text1.Text = input1 & operand2

number1 = 0

number2 = 0

decimal3 = False

End Sub

'Divide

Private Sub Command6_Click()

operand = 3

operand2 = "/"

Text1.Text = input1 & operand2

number1 = 0

number2 = 0

decimal3 = False

End Sub

' Multiply

Private Sub Command7_Click()

operand = 4

operand2 = "*"

Text1.Text = input1 & operand2

number1 = 0

number2 = 0

decimal3 = False

End Sub

' POINT

Private Sub Command8_Click()

decimal3 = True

End Sub

' ANS

Private Sub Command9_Click()

If operand = 0 Then

input1 = input3

Text1.Text = input1

End If

If operand > 0 Then

input2 = input3

Text1.Text = input1 & " " & operand2 & " ( " & input2 & " ) "

End If

End Sub

This can be transalted into other VB scripts as the code is quite simple and easy to follow however i have put headings for each section as a guide to it's function

User Avatar

Wiki User

15y ago

What else can I help you with?