Recent Posts
MySQL | 1 sec ago
Java 5 | 2 sec ago
SQL | 12 sec ago
None | 13 sec ago
None | 36 sec ago
Java | 44 sec ago
C++ | 50 sec ago
PHP | 1 min ago
Email | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
By KnifeySpooney on the 10th of Feb 2010 12:47:59 AM
Download |
Raw |
Embed |
Report
Function simpCalc(ByVal str As String) As Integer
Dim i As Integer
Dim idx As Integer
Dim subs As String
Dim nums(1) As String ' two numbers to calculate
Dim opType As Integer = -1 ' 0=add,1=sub,2=mult,3=div
While str.Length > 0
idx = IIf(opType > -1, 1, 0) ' returns 1 for index if on second num
subs = Microsoft.VisualBasic.Left(str, 1)
If Val(subs) > 0 Then
nums(idx) &= subs
ElseIf idx = 0 Then
If (subs = "+") Then
opType = 0
ElseIf (subs = "-") Then
opType = 1
ElseIf (subs = "*") Or (subs = "x") Then
opType = 2
ElseIf (subs = "/") Or (subs = "\") Then
opType = 3
End If
Else
End While
End If
str = str.Substring(1)
End While
Select Case (opType)
Case 0
i = Val(nums(0)) + Val(nums(1))
Case 1
i = Val(nums(0)) - Val(nums(1))
Case 2
i = Val(nums(0)) * Val(nums(1))
Case 3
i = Val(nums(0)) / Val(nums(1))
Case Else
i = 0
End Select
Me.txtDebug.Text = nums(0) & " " & nums(1)
Return i
End Function
Submit a correction or amendment below.
Make A New Post