Split a string in to two Integers

lkrterp

Member
Joined
Jul 10, 2007
Messages
21
Programming Experience
Beginner
Hi All,

I am trying to split a field retrieved from a database and multiple the two numbers together.

Example

Field retrieved 12/2 as string.

I need to multiple the 12 * 2 and then multiple that against the cost of an item.

I know I can possibly use the split function, but am not sure where to go from there. I found this code, but not sure how to manipulate it to multiple the two numbers

Dim i As String = "12/2"
Dim a() As String
Dim j As Integer
a = i.Split("|")
For j = 0 To a.GetUpperBound(0)
MsgBox(a(j))
Next

Can someone please help me or give me another suggestion?

Thanks
 
VB.NET:
		Dim s As String = "12/2"
		Dim arr() As String = s.Split("/")
		Dim product As Integer = Integer.Parse(arr(0)) * Integer.Parse(arr(1))
 
Back
Top