String With Commas, How To Use Instr And Mid Function In A Loop?

I have a string --> 7,8,9,10. This string may contain more or less than 4 numbers.
I want to separate each number and run an sql query for each number.

for example:

select * from table1 where code = '7'

select * from table1 where code ='8'

and etc....

Can I do this in a loop?

View Replies


ADVERTISEMENT

Instr Type Function

I've been given a large database of "model numbers". based on these model number I have to do something different. example model numbers:

B2020-SG1
B2020-SG4440
B2020-LG3
B2020-LG33E
B2020-SG1-SG1
B2020-SG1TD9-SG1
B2020-SG1TD15-SG4440

Basically, the first number (B2020, which could be a number of different numbers) is the model. the second and/or third number is what I have to act on. The problem is, how do I pull that third number? Especially if its the same as the first number. right now I'm using Instr(variable1, "SG1") to pull each different set of numebrs. but that only finds the first occurence. what about the 2nd? how can I find that?

View Replies View Related

Instr Function Generates Error

My question is

I use:
-----------------------------
dim strText,pos
strText = "This is a test!!"
pos = Instr(strText,"a",1)
response.write pos
-----------------------------
and i get:

Type mismatch: '[string: "This is a test!!"]'

What's going on?

View Replies View Related

Remove Commas From End Of String

Using ASP/VB I need to remove unwanted commas from the end of a field
that will be use in an array. There are items in the field that are
comma separated, so I don't want to remove them, just the end ones,
could be anywhere up to 5 unwanted commas.

Any ideas?

View Replies View Related

Function In The InStr Function

I want to use the instr function, but return results from it depending on surtain functions, I can't realy explain so I'll show my example:

I have a string in wich some word I want to find might be in diffrent Capital Letters order, I want the Instr function to return all the values of the place of that word (avcourse I'll run a for and increase the starting point of the Instr func until it returns 0). The instinct thought is to use the Lcase or the Ucase functions, but in this case I don't know how to use them. In the same Idea I wanted to use the Instr Func with the trim Func, But Its realy the same principle if I just understood how to do so.

View Replies View Related

Split Function & Loop

I am trying to loop around a split and the code I have is below:

response.Write("<tr>")
    response.Write("<td class=""tableHeader"" valign=""top"">Keywords</td>")
    keywordsSplits = Split (keywords, ", ")
    For each keywordsSplit in keywordsSplits
        response.Write("<td>")
        response.Write(keywordsSplit)
        response.Write("</td>")
    Next
response.Write("</tr>")

The problem is that it does actually put the seperate keywords into seperate cells (td's)
I get the following:

<tr>
    <td class="tableHeader" valign="top">Keywords</td>
    <td>test test1 test2 test3</td>
</tr>

I actually want

<tr>
    <td class="tableHeader" valign="top">Keywords</td>
    <td>test</td>
    <td>test 1</td>
    <td>test 2</td>
    <td>test 3</td>
</tr>

Can anyone help?

View Replies View Related

Function Return Breaking For Loop

Can anyone tell me why the funciton checkCode returning in the middle of the for loop breaks the for loop? ie. If I remove the section:

if checkCode("0011") = 1 then
response.write "<br />Passed submission of user code"
else
response.write "<br />failed submission of user code"
end if

from the code snippet below, then the code will successfully loop through and print out all the post var fields (there are in fact 4).

If however you leave this in, the function returning seems to break the for loop from continuing through all the other post variables after "user_code" Code:

View Replies View Related

ASP String Function

I'm looking for a string function to take a url and pull out the word between the dots, for example the url http://www.example.com would return the word example. The only criteria is because I don't know how long each url is I need to extract the word between each dot.

View Replies View Related

Mid Function To Extract String Value

6408373-SALE-11/1/2007

From string, i want to extract "SALE"

How to do it using mid and Instr ?

Also,

6408373-DECLINE-11/1/2007

From string, i want to extract "DECLINE". How to do it using mid and Instr ?

View Replies View Related

ASP String Function Does Not Work

I'm trying to figure out why the Left function doesn't seem to work.

One of the pages fails with an error:
Microsoft VBScript runtime error '800a000d'

Type mismatch

/status.asp, line 45

Line 45 is:

response.write Left("This is A Test!", 6)

Where is the Type mismatch? All my references say this should work, and give me "This i" as output. The Right function doesn't work either. But the MID function does work.

View Replies View Related

String Function Reference In ASP And ASP.net

I wanna know all String function reference in ASP and ASP.net. Is any website provide this information?

and Is string function in ASP and ASP.net has same.?

View Replies View Related

Pass XML String To Function

This example outputs "XMLString = Data 1Data 2." When I pass XML string in ASP, i
will output the data only, without <data> anymore. Then how can I retrieve the data one by one? .....

View Replies View Related

Trimmed String After Replace Function

In the ASP page that is in question, I build a large string (no more
than 10K) which is basically an email template in HTML format. Then I
replace the parts with the values, which are also strings with the size
of 1-2 KB. Code:

View Replies View Related

Instr

Why does this code Code:

Dim mytext
mytext = "Tristique, sed tamen typicus amet, bene quia feugait eu. "
Response.Write Instr(mytext, "tamen")

Gives the response "16"? Surely this word only appears once? Is it counting letters? How can I make it identify just words?

View Replies View Related

InStr

How do I use InStr to find the string d="1"

I have tryed:

InStr(text,"d=&quot;1&quot;") and it does not work

I have tryed a few other variations and I cant get it to work.

View Replies View Related

Access, Not Instr

I dont want those Disp selected from access db...I am getting an error..How will I do that ?
Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: "49, 50"]'

/drv_sch/Generate_Sch.asp, line 55
----------------------------------------
Driver_id is a number...Disp variable has these data "49, 50, 51"
SELECT * FROM schedule WHERE not instr('Disp',driver_id)

View Replies View Related

Trimming Commas

I'm dynamically building an SQL string to do an execute, and keep ending up with a leftover comma, so the string looks like this.

INSERT INTO Software ( Title, Version, Licensing, Total_Licenses, support_phone, support_email, Campuses_Licensed, Comments, support_web, FundingSource, Course_title, Subject, Grade_level, LocalExpert, ACTIVE, CATE, EntryDate,) VALUES ( 'Bob's Super Crappy Software', '4.3', 'labpack', '36', '555', '555', 'Alexander, Bilhartz, Central, Fairmeadows, Hyman, Daniel', 'James is testing this', 'www.bob.com', 'Campus PO', 'Math', 'Math', '4, 5, 6', 'Patrick Williams', '1', '0',)

Both commas are added dynamically and can be trimmed on the fly. I tried using RTRIM(strSQL, ",") but this didn't work.I put the fields into an array and tried to add only commas to all but the last entry, but that also didn't work.

View Replies View Related

CSV Commas In Data

How is the best way to handle commas in data in CSV files? I'm currently using the following:

set fso = createobject("scripting.filesystemobject")
set act = fso.opentextfile(server.mappath("filename.csv"))
itext = act.readall
arrlist = split(itext,chr(10))

and then looping through the rows and splitting at commas. However, some of the data has commas in it, which is throwing things off.

View Replies View Related

Instr Searches

I am searching a string that look like this (21,5,15,25) using Instr().
So, if I am searching for '5', I get everything that contains a five.

If InStr("21,5,15,25", req,QuerStr("id") Then
response.write "yes"
End If

I want only the one value '5' to get found but anything that contains a 5 is found. I have tried using Cint and Int to no avail.

View Replies View Related

Adding Commas

4 months into the land of ASP and I still have newb questions.I have a simple string.

centertype = Type1 & Type2 & Type3 & Type4 & Type5

How do I add a comma to seperate this string? Keep in mind that some of the values may be blank.
i.e. Type1 = ""
or Type4 = ""

View Replies View Related

InStr, Substr, Mid

I have a field name "tracks" of string data type that has multiple names in it (for example: calder delaware$ aqueduct ), and I want to check to see if this certain field has "delaware$" in it. InStr or the Mid functions return the numerical order of where that string starts inside the string, but it doesnt tell me if "delaware$" exists in "tracks".

View Replies View Related

Replace :: Commas

I need to create a string along the lines of "23,43,78,23" with no comma at the beginning or end of it. The data comes out of a table so i've created a loop to get the data and form the string :

StrRecip = "," & objRS("number") & StrRecip

This will give me something like : ",42,78,67,2,90"

And then I've removed the leading comma :

StrRecipRem = replace(StrRecip, ",", "", 1, 1)

Is there actually a better way ?

View Replies View Related

Instr() - Meaning

was the instr() in asp means... meaning - why it is used.

View Replies View Related

Reliable Instr() ?

Using MySQL as a DB, I'm generating an OTF SQL statement that looks for matches in a comma delimited string. The code ends up looking something like this: Code:

View Replies View Related

Left And Instr Functions

I am having a problem with the following code:

<%
If Len(TestRS.Fields.Item("Testimonial").value) > 150 Then
Response.Write(Left(TestRS.Fields.Item("Testimonial").Value,150)&""... <br><font size=1><a href=""/Testimonials.asp"">Read More</a></font>")
Else
Response.Write(TestRS.Fields.Item("Testimonial").Value)
End If
%>

I am getting a null response from TestRS.Fields.Item("Tesimonial").Value after it is processed by the Len function.

I am getting the following result: Quote: "... Read More This tells me that the len function is analysing the string to be greater than 150 charachters yet the string is not being expressed.

View Replies View Related

Import From Csv - Remove Commas

I'm importing data from a csv file but have the following problem.

It see any comma in a specific column as the end of the current column and move the rest of the values into the next column I.E Data from column 4 display as data from column 5.

I do know that it's comma delimited but would like to know if there's no way that I can distinguish between the commas in a column and the commas that indicate a new column.

Col1 Col2 Col3 Col4 Col5
Value Value Value Val,ue Value


How do they do it in excel?

View Replies View Related

Commas Getting Inserted Into Database

I don't know if anyone has encountered this before. I've written ASP code to insert, update and delete records from Access and SQL Server tables before but this is the first time I face this issue -

I have a form that inserts data into an Access table. For a few of the fields, commas are getting inserted into the table. If the field is left blank, there is a comma inserted. If we enter data in the field, the comma is appended to the field value (eg: smith, )

The only thing different that i'm doing here from what I've done before is I'm inserting a larger number of fields into the table - 117 fields!!

Do you think the insert statement hasn't been written correctly?

View Replies View Related

Should I Use LIKE Or InSTR For A Database Search?

Which is better practice?

Code:
Select * From groups Where groupName LIKE '%bli%' AND cusType LIKE 'CUST%'
or

Code:
Select * From groups Where InStr(groupName,'li')>0 AND InStr(cusType,'CUST')=1
Right now I'm using and Access database but plan to upsize to a MSSQL if that makes any difference. Are there any advantages or disadvantages to either technique?

View Replies View Related

Commas Not Full Stops

I have a price field in a cms,it can deal with full stops fine, but i cant understand why it wont accept commas.

View Replies View Related

InSTR Is Case Sensitive

Just used this code and noticed it doesn't always work, turns out InStr is case sensitive.What's thet best way to do a non-case sensitive search?pHP Code:

IF INSTR(VideoName,"HiRes") THEN 

View Replies View Related

Display Data Between Commas

I would like to know if you can display only certain data into a field between commas or any other symbol without using the curshort feature. For example. I have the following.

Part, A3472, Desc: Controller: Price$ 45.00

I just need this out of it in a single form field.

A3472

I cannot use the cutshort feature because my part numbers are different lengths.

View Replies View Related

Remove Commas And Space

let say i got a string:

apple, orange, durian

how to check got how many commas in this string? how to check beside the commas is space or not space? if the words beside the commas is space, i wan to remove the space? if the words got commas, i have to remove the space.

View Replies View Related

Removing Commas From Csv File

having problems removing commas from my form input. Have a form that is bringing back text strings from users. when it gets put into CSV file, any commas the user has entered get moved onto new rows.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved