ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   ASP / VB Assistance (https://www.scoobynet.com/computer-and-technology-related-34/169633-asp-vb-assistance.html)

rik1471 21 January 2003 02:13 PM

I have an ASP form with a selection box populated via an SQL table. Some of the options have a section of text at the end of the string which I need to delete before the data is passed to the next page.

E.G. If the string from the dataase reads

Extorsion e.g. illegal emails requiring payment.

Then I need the data from the form field, being POST'd to the next form to just be 'Extorsion', not the 'e.g. illegal emails requiring payment.'

I suspect it has something to do with strdelete or strwhere, but i've had no real experience with these commands.

As each result will have the 'e.g. Unrequired data' it will be everything before th e.g. which I need to keep.

I hope this is clear??? :rolleyes:, but you know when you have it in your head but can't explain ;)

Thanx.

Rik.

Rob Walker 21 January 2003 02:28 PM

Can't you just do something like...

newstring = Left$(oldstring, InStr(oldstring, "e.g."))



rik1471 21 January 2003 02:32 PM

Will that delete everything after the 'e.g.' including the 'e.g.'??

Rob Walker 21 January 2003 02:34 PM

yeah.. will create a new string with everything before the e.g.

rik1471 21 January 2003 02:35 PM

Cheers :)

rik1471 21 January 2003 02:48 PM

Little problem,

I have a variable 'threat1=request.form("threat")' which holds the data 'Extorsion e.g. illegal emails requiring payment.'

I've used your code as follows: 'threat = Left$(threat1, InStr(threat1, "e.g."))' to hopefully pass the variable 'threat' to the next page without the e.g. illegal emails requiring payment.'

When I submit the form it errors: Error Type:
Microsoft VBScript compilation (0x800A0408)
Invalid character
/new_cit/risk/vulnerabilities/vulnerabilities1.asp, line 29, column 13'

I take the $ out of the code and it passes 'Capacity Overload e' as the edited variable. It won't delete the final e, any ideas??


AdrianFRST 21 January 2003 03:07 PM

Adding a space to "e.g" worked for me: InStr(threat1, " e.g."))

Leaves a space though so just trim it: trim(InStr(threat1, " e.g.")))

I've never seen $ used in VBScript, just PHP, Perl etc.

rik1471 21 January 2003 03:12 PM

Sorry to be a pain, but some of the options don't have the 'e.g.' at the end, so if you select one that doesn't at the moment it deletes everthing. How can I check to see if e.g. exists in the string and then delete the data if it does.

:) thanx.

Dream Weaver 21 January 2003 03:33 PM

Can you not separate the content into a new table? i.e. have a new table with all the e.g. bits in, then just link them together when doing the initial recordset for the form.

Otherwise, just do an If(Instr(e.g.))= true then delete else, dont delete, end if etc

Cant be ased typing full syntax, but you get the drift. :)

rik1471 21 January 2003 04:09 PM

Could someone help me with the full syntax. I'm not very familiar with this. :rolleyes:

Dream Weaver 21 January 2003 04:48 PM


IF InStr(threat1," e.g. ")= True THEN
strThreat1 = Left$(threat1, InStr(threat1, " e.g."))
ELSE
strThreat1 = threat1
END IF

Fosters 21 January 2003 05:27 PM

Shouldn't it be
IF INSTR(threat1," e.g. ")>0 THEN
'IT'S THERE
ELSE
'IT'S NOT
END IF

?

Dream Weaver 21 January 2003 05:29 PM

Possibly - didnt test it, just wrote it :D

Could also be blah blah = 1 as well.

Just test all three possibilities

rik1471 21 January 2003 05:37 PM

That's it Fosters :D - cheers!

Thanx DW, Adrian & Rob. :D



All times are GMT +1. The time now is 05:36 AM.


© 2024 MH Sub I, LLC dba Internet Brands