having problem getting string into Array 
Author Message
 having problem getting string into Array

I have a form that passes selected text values to myProcess.asp like
this:
  myString = "100, 120, 135"

I want to do a loop and grab values one at a time because they have to
be saved into a table with other related fields from my form like
this:

Array = myString(3)  
For i - 1 to 3
    sql = "input myTxtField1 into myTable values('myString(i)')"
    set rs = conn.execute(sql)
next

I tried a bunch of things but I am doing something wrong. How can I
parse this string and save the values into 3 different records?  In
JavaScript I would create an array using the split function. Does
someone have example code that I can see? I tried examples I found on
the web but I'm not getting it.

Thank you!



Mon, 18 Oct 2004 20:11:35 GMT  
 having problem getting string into Array
Try this

Quote:
> For i - 1 to 3
>     sql = "input myTxtField1 into myTable values('" & myString(i) & "')"
>     set rs = conn.execute(sql)
> next

JP


Quote:
> I have a form that passes selected text values to myProcess.asp like
> this:
>   myString = "100, 120, 135"

> I want to do a loop and grab values one at a time because they have to
> be saved into a table with other related fields from my form like
> this:

> Array = myString(3)
> For i - 1 to 3
>     sql = "input myTxtField1 into myTable values('myString(i)')"
>     set rs = conn.execute(sql)
> next

> I tried a bunch of things but I am doing something wrong. How can I
> parse this string and save the values into 3 different records?  In
> JavaScript I would create an array using the split function. Does
> someone have example code that I can see? I tried examples I found on
> the web but I'm not getting it.

> Thank you!



Mon, 18 Oct 2004 21:13:58 GMT  
 having problem getting string into Array
If myString = "100, 120, 135", do I have to do anything else to myString
first, like tell VBScript that it is an Array?


Quote:
> Try this
> > For i - 1 to 3
> >     sql = "input myTxtField1 into myTable values('" & myString(i) & "')"
> >     set rs = conn.execute(sql)
> > next



Mon, 18 Oct 2004 21:51:43 GMT  
 having problem getting string into Array

Quote:

> If myString = "100, 120, 135", do I have to do anything else to myString
> first, like tell vbscript that it is an Array?



Option Explicit
Dim myString: myString = "100, 120, 135"
Dim myAry, myItem

myAry = Split(myString, ", ")
For Each myItem in myAry
 MsgBox myItem
Next

From VBS documentation:
    Split Function
    Returns a zero-based, one-dimensional array containing a
    specified number of substrings.

    Split(expression[, delimiter[, count[, compare]]])

Branimir



Mon, 18 Oct 2004 22:14:15 GMT  
 having problem getting string into Array
Try using the split function.
Quote:

> I have a form that passes selected text values to myProcess.asp like
> this:
>   myString = "100, 120, 135"

> I want to do a loop and grab values one at a time because they have to
> be saved into a table with other related fields from my form like
> this:

> Array = myString(3)  
> For i - 1 to 3
>     sql = "input myTxtField1 into myTable values('myString(i)')"
>     set rs = conn.execute(sql)
> next

> I tried a bunch of things but I am doing something wrong. How can I
> parse this string and save the values into 3 different records?  In
> JavaScript I would create an array using the split function. Does
> someone have example code that I can see? I tried examples I found on
> the web but I'm not getting it.

> Thank you!



Sun, 14 Nov 2004 21:28:19 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. having problems getting the Inet Control to receive an entire html file

2. String to Array and Array to String

3. Fun with APIs- Getting an array of records with pointers to strings

4. Getting an array from a long string

5. Getting a string out of a C byte array

6. Getting an array of records with pointers to strings from an API

7. getting a spec element in multiple elements having same id att

8. getting query string from frame in jscript and getting frame name from another frame

9. Problem reading image data into an array of strings

10. Having trouble saving array in Session object

11. Problem while testing string array argument of ATLCom object in VB script client

12. MSCOMM problem: buffer string is getting too big.

 

 
Powered by phpBB® Forum Software