| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: how can a math operator be set as a variable? |
On Tue, 25 Jan 2005 01:12:32 GMT, "andrew" wrote:
[snip some code]
I would start off by saying something in the body of the message.
Option Explicit
Public dValue1 As Double, dValue2 As Double
Private sOper As String * 1
Private Sub Form_Load()
sOper = "*"
dValue1 = Val(txtMain1.Text)
dValue2 = Val(txtMain2.Text)
dResult = Eval(dValue1, sOper, dValue2)
txtMain2.Text = CStr(dResult)
End Sub
Function Eval(Val1 As Double, Op As String, Val2 As Double) As Double
Select Case Op
Case "+"
Eval = Val1 + Val2
Case "-"
Eval = Val1 - Val2
Case "*"
Eval = Val1 * Val2
Case "/"
Eval = Val1 / Val2
Case "^"
Eval = Val1 ^ Val2
Case Else
Eval = 0
' or could raise an error
End Select
End Function
--
auric underscore underscore at hotmail dot com
*****
When you say "I wrote a program that crashed Windows", people just stare
at you blankly and say "Hey, I got those with the system, *for free*".
-- Linus Torvalds
--- UseNet To RIME Gateway {at} 1/25/05 6:44:31 PM ---
* Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)SEEN-BY: 633/267 270 5030/786 @PATH: 278/230 10/345 106/1 2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.