Split Array Evenly Into More Arrays
arrContents = Split(strContents, vbCrLf)
but now i want to divide the contents of "arrContents" evenly and randomly into 6 other arrays.
How can i go about doing this?
arrContents = Split(strContents, vbCrLf)
but now i want to divide the contents of "arrContents" evenly and randomly into 6 other arrays.
How can i go about doing this?
I have a string
212334||327362737||437437||47347837||8347834||
etc
but i want to enter them into a databse
but it must be as 1356235 then field 2 is 125662
dont know if this makes sense
each number is a team in a match so team 1 plays team 2, enters into databse
then move on to the next 2, in that array.
i cant seem to get it to do 2 at a time, without ending up with an endless loop or team 2 being team 1 on the second entry.
How can I split an array to string?
View Replies View Relatedi have a text box, where i want to be able to enter items on a one per line basis.
i then need to insert these items into a database.
i have the functionality to insert into the db ...
I'm trying to make a recursive program and I need to store an array of visited states. Each state is another array and I think there is no way of doing it with vbscript classic (not .NET). The thing would be something like that (not recursive)
Dim state(3,3)
Dim visitedStates(50)
initializeState(state)
visitedStates(1) = state
changeState(state)
visitedStates(2) = state
I don't know if I could store it in a three dimension array. More or less like visitedStates(50,3,3).
I am developing this web application where users may go through a number of steps to "build their product". This is all done with session variables to hold the input until submitted. The way I have it right now,
There is about 16 checkboxes, all with the same name "checkbox" (for simplicity) Each has a different id and different value.
The user may only choose 3. The values from these get stored in a comma deliminated string: ie. about, testimonies, services.
(I am trying to avoid setting a variable for each checkbox to be equal to, which I tried and it didn't work.)
If the user goes back to the page if they change their mind I want the appropriate checkboxes to be checked.
Right now I have the string being split up into an array. I have tried setting the array values to variables, then I tried setting these equal to another specific variable only for that checkbox..blah,blah, blah.
Here is my code, very similar to someone's on the forums (which I have been going through with a fine tooth comb, ; turns out their thread was never answered).
This code gets the first array item and checks the right checkbox but no the other 2.
<%
menuarray = Split(Session("checkbox"),",")
for i = LBound(menuarray) to UBound(menuarray)
'currentCardType = ""
response.write " " & i & " = " & menuarray(i) & "<br>"
next
' because there is only 3 for sure, I just used 0-2 rather than i for the following.
' I have the following three times in my code, for the 3. Tried it with just "i" and within the loop but didn't work
if CStr(menuarray(0)) = CStr("Welcome") then
vWelcome = "checked"
elseif CStr(menuarray(0)) = CStr("About Us") then
vAbout = "checked"
elseif CStr(menuarray(0)) = CStr("Message from the President") then
vMessage = "checked"
elseif CStr(menuarray(0)) = CStr("Products and Services") then
vProducts = "checked"
elseif CStr(menuarray(0)) = CStr("Our Services") then
vServices = "checked"
elseif CStr(menuarray(0)) = CStr("Curriculum") then
vCurriculum = "checked"
elseif CStr(menuarray(0)) = CStr("Testimonials") then
vTestimonials = "checked"
elseif CStr(menuarray(0)) = CStr("Student Life") then
vStudentlife = "checked"
elseif CStr(menuarray(0)) = CStr("Apply Now") then
vApply = "checked"
elseif CStr(menuarray(0)) = CStr("Case Studies") then
vCasestudies = "checked"
elseif CStr(menuarray(0)) = CStr("Catalog") then
vCatalog = "checked"
end if
.....
I'm developing a site in which I'm supposed to daily display an array of images into a table in a page. The question is : Is there any code in asp that could help me perform the splitting of the array and consequently displaying it in the tables along the pages, (considering the necessity of displaying it in more than one page) ,automatically ? The problem is that these arrays of images do not have a constant length, actually, I can read the content of items in a certain folder, before creating the array and, according to that number I should set it to be splitted in "x" pieces that should be displayed in "x" pages, within tables. If it was a fixed number of items I wouldn't have much trouble, but this number varies, daily.
View Replies View RelatedI am having trouble loading the result of a VBscript split function into an array. The script is supposed to take the user's login name (the form for this is name separated by underscores such as john_foo or lisa_wilson), split it at the underscores, and load first, middle and last name into an array. The problem I keep getting though, is that I am getting a type mismatch error. Here is the code:
<%dim LogName, NameArray(), FirstName, LastName, MiddleName, LastPage
'Get NT authorized login info
LogName = request.servervariables("logon_user")
NameArray = Split(LogName, "_")
for x = 0 to UBound(NameArray)
response.write NameArray(x) & "<br>"
next
%>
The FirstName, MiddleName, LastName vars are supposed to take the array values later.
I am retrieving a set of values from some checkboxes in a form. When I put the values into a variable it prints fine:
Code: .....
I have a variable which holds college names
strcollege="University of California"
i want a variable to save UoC
what i meant was there are 3 words University of California
so i want the first letter in each word to be stored in a variable ....
I dump the entire recordset into an array:
If not rs.EOF Then
aEmp = rs.GetRows()
Contents of the array are in this order:
EmpID,EmpName,Indent,Sub_ID,Lft,Rgt,MgrID, LastName
This query sort on the basis of Lft and Rgt columns.
The name of the array is: aEmp.
My question here is how can I get only the LastName from the aEmp array into another array so that I can sort the names alphabetically and then display the employees in the alphabetical order.
Or is there is another way I could this by using the same array while keeping the lft and rgt sort of the query? If I sort based at the SQL query level, I can see the names sorted by the lft, rgt and lastname, but since the lastname is at the end of the sort list - it does not appear alphabetically.
In working with arrays, I have found that I am unable to dimension and array
with a variable that has an integer value but I can redimension one this
way. I haven't see any information that tells me if this is a requirement,
although it appears to be because I get an error if I try it.
Ex.
Dim b
b = 10
Dim a(b) ' this errors out but
Dim a() ' this
Redim a(b) ' works
Code:
One of my fields is the customer's social security number, all originally
entered as a 9-character string. How can I split and display that into 3-2-4
format?
As I can split a string that contains char " "
split(string, " ") it is not correct
What I need to do is get the content of a text file, one line at a time, and break it up using , as a delimiter.
So far I can open the file and print out all the content, but all I am getting is a million ???????'s on the screen, and not the file. Here is what I am using: Code:
How can I calculate the number of the substrings below?
Code:
Dim txt
do until rs.EOF
txt=Split(rs("diastima"), ",")
For i=1 to number_of_substrings
Response.Write txt(i)&"<br>"
next
rs.MoveNext
loop
I have value sSearch = Lastname Firstname
I need to split it into two separate field:
sLast = Lastname
sFirst = Firstname
I tried
arrSearch = split(sSearch, " " )
but how do I actually get the values?
I need to send a mail for each address I found in one var. The var is as follows:
emails = "onemail@onedomain.com , other@othermail.com , another@another.com "
How Can I make a "do while var not end"?
I have trouble working with arrays in asp.. I have the following error :Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: 0]'
the line that gives me the error is the following:
Door_OpeningValH= aDoor_OpeningVal(0)
and my code is this:
Door_OpeningVal= rs("Door_Open_Dimension")
aDoor_OpeningVal = split(Door_OpeningVal, "x", -1, 1)
Door_OpeningValH = aDoor_OpeningVal(0)
aDoor_OpeningValW = split(aDoor_OpeningVal(1)," ",-1,1)
Door_OpeningValW = aDoor_OpeningValW(0)
Door_OpeningValUnit = aDoor_OpeningValW(1)
what i'm doing is recivieng values from 2 textboxes and a combo box.I want it to save in my database like this:
2x5 ft
I need to create a multidimensional array using another int as one of the criteria but I keep getting probs with my code, what am I doing wrong?
Code:
intMonthName = Cint(Month(field_in_my_database))
Dim myarray(intMonthName,2,5)
I get this error message:
Quote: Microsoft VBScript compilation error '800a0402'
Expected integer constant
I am using ASP with VBScript and I want to know how to seperate a 2 dimensional array into 1 Dimensional arrays:
like if
MyArray is a 2 D array and I want to store the first row of this array in another array , like in C
MyArray[5][5] //this is a 2D array
OneDimArray=MyArray[0] // stores the first row of the 2D array in OneDimArray
is there a way to do it in VBScript ????
I couldn't find a way
I don't want to do it with loops I hate code with too much loops,
How can display unique values from an array. I dont want to loop thru all the values and do it. Is there a better way?.
View Replies View RelatedWhat does the numeral '1' mean in the following statement?
For J = 0 to UBound(QArray, 1)
I have an array in ASP and I am populating the array with the values from database on checking a condition. Lets say i have array of arr(5). Initially I made all the array items null ...
View Replies View RelatedI have an array in ASP called WordsArray() which contains several words. What I would like to do is search the array for a word, and if its not there, add it to another array ResultsArray()
So far, a loop in my code only checks the current array value, and not the rest of the array, adding the search word to the end of the resultsArray regardless.
I want to take a server variable and split it. It would look something like this:
varServerVariable = fistname.lastname
I want it to look something like:
first = firstname
last = lastname
I know that I need to use the Split Function, but I'm not sure of the syntax.
Plz guide me on the follwoing..
database=storedb
table=product
for e.g i m having 50 records in databse i would like to display the 10 records
on one page and other on second page and so on.. using asp.
I have a section where users can add their 'favourite venues' to a list. This is stored in a column in the users table, for example:
10,8,1,18,26
On the user area I can do a select drop-down with all their favourite venues easy.
When I try to use the same (slightly modified) code on the venue detail page to determine whether the user has the venue in their favourite to link either to ADD venue (not currently a fave) or REMOVE venue (already on the faves list) it only recognises the last added venue, i.e. (working on the list above) venue #26.
Here is the code I'm using: Code:
What I'm trying to do is to split up a value into two images.
For example: Rs("num") displays "12". How do i display the 12 as "1.gif" and "2.gif"?
how can I double split this string and pu the values into an array?
string = 2_3, 4_5, 6_8;6_9, 4_6; 3_1
I need the split after "," and ";"
I am looking for a function to split my string into subsequent parts. I am having a textbox from where user can enter more then one numbers (23, 456, 89, 394 etc), and now I want to write a function which return this sting into this fashion i.e.
23
456
89
394
there is a method to split a string with a delimiter
checkDelete = Request("checkDelete")
arrayDelete = Split(checkDelete, ",")
my string is Trim(arrayDelete(i)), that has the format "number_number".
I want to put the two numbers in two different variables.
i am trying to split an email address into a string.Basically, what i wanna do is take the first part of the email just before the "@" symbol and insert it into the database.
How can I do this using asp?