Jump to content

Problem with StringSplit?


Damein
 Share

Recommended Posts

So I have this code, and it works so long as I don't use a number with more than one digit.

So, its just a test to figure out how to fix a problem in my other script.

Example:

2*2*2*2 comes out as: 16

Which, that works out correctly.

But:

2*22 comes out as: 4, not 44.

Here's the code:

Global $StoreProblemGrid, $result, $StartingNumber, $Count, $NumberToStartWith, $SaveNumbers

            $StoreProblemGrid = InputBox(0, "Test", "Input problem")
            $result = StringSplit($StoreProblemGrid, "*")
            $StartingNumber = $result[0]
            $Count = 1
            $State = 0
            $StartingNumber -= 1
            $NumberToStartWith = $result[1]
            Do
                $Count += 1
                $StartingNumber -= 1
                $NumberToStartWith *= $result[$Count]
                If $StartingNumber = 0 Then
                $SaveNumbers = ""
                $state = 1
                $Count = ""
                MsgBox(0, "Test", $NumberToStartWith)
                $NumberToStartWith = ""
            EndIf
        Until $state = 1

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

You have quite a mess in there - I didn't even try to debug your code, I just re-wrote it:

Global $StoreProblemGrid, $compos, $result

    $result = 1
    $StoreProblemGrid = InputBox(0, "Test", "Input problem")
    $compos = StringSplit($StoreProblemGrid, "*")
    For $i = 1 To $compos[0]
        $result *= $compos[$i]
    Next
    MsgBox(0, "Test", $result)

Edit: BTW - StringSplit returns the number of elements in [0], so first element will be [1] -> $StartingNumber = $result[1] ... if you want to debug your code ...

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...