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...
Learn a little bit about the new Pastebin.com on our help page. hide message
By KnifeySpooney on the 10th of Feb 2010 12:47:59 AM Download | Raw | Embed | Report
  1.     Function simpCalc(ByVal str As String) As Integer
  2.         Dim i As Integer
  3.         Dim idx As Integer
  4.         Dim subs As String
  5.         Dim nums(1) As String ' two numbers to calculate
  6.        Dim opType As Integer = -1 ' 0=add,1=sub,2=mult,3=div
  7.        While str.Length > 0
  8.             idx = IIf(opType > -1, 1, 0) ' returns 1 for index if on second num
  9.            subs = Microsoft.VisualBasic.Left(str, 1)
  10.             If Val(subs) > 0 Then
  11.                 nums(idx) &= subs
  12.             ElseIf idx = 0 Then
  13.                 If (subs = "+") Then
  14.                     opType = 0
  15.                 ElseIf (subs = "-") Then
  16.                     opType = 1
  17.                 ElseIf (subs = "*") Or (subs = "x") Then
  18.                     opType = 2
  19.                 ElseIf (subs = "/") Or (subs = "\") Then
  20.                     opType = 3
  21.                 End If
  22.             Else
  23.                 End While
  24.             End If
  25.         str = str.Substring(1)
  26.         End While
  27.         Select Case (opType)
  28.             Case 0
  29.                 i = Val(nums(0)) + Val(nums(1))
  30.             Case 1
  31.                 i = Val(nums(0)) - Val(nums(1))
  32.             Case 2
  33.                 i = Val(nums(0)) * Val(nums(1))
  34.             Case 3
  35.                 i = Val(nums(0)) / Val(nums(1))
  36.             Case Else
  37.                 i = 0
  38.         End Select
  39.         Me.txtDebug.Text = nums(0) & " " & nums(1)
  40.         Return i
  41.     End Function
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: