Using Split

1. Senior Member
Join Date
Dec 1969
Posts
103

## Using Split

I have two variable with the following numeric numbers.<BR><BR>Number1 = "1222.11"<BR>Number2 = "3212.99"<BR><BR>What I&#039;m trying to do is to split each of the values from the period. I&#039;m trying to add the value that is to the left of the perio as a new number and to add the values to the right of the period. <BR><BR>Number1 and Number2 changes the values all the time so thats why I can&#039;t do this manually.<BR><BR>Any Ideas?

2. Senior Member
Join Date
Dec 1969
Posts
261

## RE: Using Split

Will there always be 2 numbers after the "."

3. Senior Member
Join Date
Dec 1969
Posts
1,032

## explanation ....

do you mean ..<BR>number1="1222.11"<BR>so <BR><BR><BR>1st add the numbers up to the decimal point<BR>1+2+2+2 = 7<BR><BR>2nd add the numbers after the decimal point<BR>1+1 = 2<BR><BR>is this what you require ???<BR><BR>jon.<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
103

## RE: Using Split

yes there is always going to be numbers after the .

5. Senior Member
Join Date
Dec 1969
Posts
103

## RE: explanation ....

The Problem is that I don&#039;t know what number are Number1 and Number2 are going to have. All that I know is that there is always going to have decimals.

6. Senior Member
Join Date
Dec 1969
Posts
261

## Now I am lost

:(

7. Senior Member
Join Date
Dec 1969
Posts
1,032

## ok ..

number1 and number2 are variables !!<BR><BR>as in the previous question , what action do you want to take on these numbers ,<BR><BR>number1="12345.67"<BR>1+2+3+4+5+6+7 = result1<BR>6+7 = result2<BR><BR>you need to clarify what U want !!!<BR><BR><BR>jon...<BR>

8. Senior Member
Join Date
Dec 1969
Posts
16,931

## Maybe I've cracked it...

...is the fact there&#039;s a dot in there not meant to mean a decimal?<BR><BR>Are you trying to do:<BR>strNumber = "1111.2222"<BR>intAnswer = 1111 + 2222<BR><BR>i.e. the period is just a delimiter of two numbers?<BR><BR><BR>Function AddUp(strNumber)<BR> Dim arrTemp: arrTemp = Split(strNumber, ".")<BR> Dim intCounter, dblAccum: dblAccum = 0<BR> For intCounter = 0 to UBound(arrTemp)<BR> If IsNumeric(arrTemp(intCounter)) Then<BR> dblAccum = dblAccum + CDbl(arrTemp(intCounter))<BR> End If<BR> Next<BR> AddUp = dblAccum<BR>End Function<BR><BR><BR>Yeah/no?<BR><BR>Craig.

9. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Or, he means..

number1 = "100.200"<BR>number2 = "300.400"<BR><BR>number1Array = Split(number1, ".")<BR>number2Array = Split(number2, ".")<BR><BR>beforeDecTotal = CLng(number1Array(0)) + CLng(number2Array(0))<BR>afterDecTotal = CLng(number1Array(1)) + CLng(number2Array(1))

10. Senior Member
Join Date
Dec 1969
Posts
16,931

## Same difference.

My way would allow there to be multiple decimal points ("111.111.111.111"), but it&#039;s the same idea.<BR><BR>Lets face it, he probably wants something completely obscure anyway...<BR><BR>Craig.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•