Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

ASP / VB Assistance

Thread Tools
 
Search this Thread
 
Old 21 January 2003, 02:13 PM
  #1  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Question

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??? , but you know when you have it in your head but can't explain

Thanx.

Rik.
Old 21 January 2003, 02:28 PM
  #2  
Rob Walker
Scooby Regular
 
Rob Walker's Avatar
 
Join Date: Nov 1999
Location: Stockport
Posts: 474
Likes: 0
Received 0 Likes on 0 Posts
Post

Can't you just do something like...

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


Old 21 January 2003, 02:32 PM
  #3  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

Will that delete everything after the 'e.g.' including the 'e.g.'??
Old 21 January 2003, 02:34 PM
  #4  
Rob Walker
Scooby Regular
 
Rob Walker's Avatar
 
Join Date: Nov 1999
Location: Stockport
Posts: 474
Likes: 0
Received 0 Likes on 0 Posts
Post

yeah.. will create a new string with everything before the e.g.
Old 21 January 2003, 02:35 PM
  #5  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

Cheers
Old 21 January 2003, 02:48 PM
  #6  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

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??

Old 21 January 2003, 03:07 PM
  #7  
AdrianFRST
Scooby Regular
 
AdrianFRST's Avatar
 
Join Date: Oct 2000
Posts: 368
Likes: 0
Received 0 Likes on 0 Posts
Post

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.
Old 21 January 2003, 03:12 PM
  #8  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

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.
Old 21 January 2003, 03:33 PM
  #9  
Dream Weaver
Scooby Regular
 
Dream Weaver's Avatar
 
Join Date: Feb 2000
Location: Lancashire
Posts: 9,844
Received 0 Likes on 0 Posts
Post

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.
Old 21 January 2003, 04:09 PM
  #10  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

Could someone help me with the full syntax. I'm not very familiar with this.
Old 21 January 2003, 04:48 PM
  #11  
Dream Weaver
Scooby Regular
 
Dream Weaver's Avatar
 
Join Date: Feb 2000
Location: Lancashire
Posts: 9,844
Received 0 Likes on 0 Posts
Post


IF InStr(threat1," e.g. ")= True THEN
strThreat1 = Left$(threat1, InStr(threat1, " e.g."))
ELSE
strThreat1 = threat1
END IF
Old 21 January 2003, 05:27 PM
  #12  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

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

?
Old 21 January 2003, 05:29 PM
  #13  
Dream Weaver
Scooby Regular
 
Dream Weaver's Avatar
 
Join Date: Feb 2000
Location: Lancashire
Posts: 9,844
Received 0 Likes on 0 Posts
Post

Possibly - didnt test it, just wrote it

Could also be blah blah = 1 as well.

Just test all three possibilities
Old 21 January 2003, 05:37 PM
  #14  
rik1471
Scooby Regular
Thread Starter
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

That's it Fosters - cheers!

Thanx DW, Adrian & Rob.

Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Darrell@Scoobyworx
Trader Announcements
26
30 January 2024 01:27 PM
Phantom_Flan_Flinger
ScoobyNet General
14
23 April 2001 10:23 PM
Rum*
ScoobyNet General
29
29 November 2000 10:05 AM



Quick Reply: ASP / VB Assistance



All times are GMT +1. The time now is 01:41 AM.