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 Help - editing text string

Thread Tools
 
Search this Thread
 
Old 23 June 2004, 04:37 PM
  #1  
rogp
Scooby Regular
Thread Starter
 
rogp's Avatar
 
Join Date: Mar 2003
Posts: 455
Likes: 0
Received 0 Likes on 0 Posts
Default ASP Help - editing text string

Hi,

I'm passing a text string from a cookie into a text field in a form.

The text is stored as Firstname<space>Surname in the cookie but in order for the field in the form to be valid it needs to appear as Firstname.Surname so that it can form an email address.

Can anyone advise me in simple terms what I need to do to manipulate the text?

Thanks

Rog
Old 23 June 2004, 05:02 PM
  #2  
GaryK
Scooby Regular
 
GaryK's Avatar
 
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes on 0 Posts
Default

There is a replace command in VBScript not sure of the exact syntax that will do what you want.
Old 23 June 2004, 10:30 PM
  #3  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

VBScript Replace Function
Returns a string in which a specified substring has been replaced with another substring a specified number of times.

Syntax: VBScript Replace Function
Replace(expression, find, replacewith[, start[, count[, compare]]])

Arguments: VBScript Replace Function
expression

A string expression containing substring to replace. Required.

find

The substring being searched for. Required.

replacewith

The replacement substring. Required.

start

The position within expression where substring search is to begin. If omitted, 1 is assumed. Optional.

count

The number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Optional.

compare

The numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. Optional.

Settings: VBScript Replace Function
The compare argument can have the following values:

Constant
Value
Description

vbBinaryCompare
0
Perform a binary comparison.

vbTextCompare
1
Perform a textual comparison.


Return Values: VBScript Replace Function
Replace returns the following values:

If
Replace returns

expression is zero-length
Zero-length string ("").

expression is Null
An error.

find is zero-length
Copy of expression.

replacewith is zero-length
Copy of expression with all occurrences of find removed.

start > Len(expression)
Zero-length string.

count is 0
Copy of expression.


Remarks: VBScript Replace Function
The return value of the Replace function is a string, with substitutions made, that begins at the position specified by start and concludes at the end of the expression string. It is not a copy of the original string from start to finish.

The following example uses the Replace function to return a string:

Dim MyString

MyString = Replace("XXpXXPXXp", "p", "Y") ' A binary comparison starting at the beginning of the string. Returns "XXYXXPXXY".

MyString = Replace("XXpXXPXXp", "p", "Y", ' A textual comparison starting at position 3. Returns "YXXYXXY". 3, -1, 1)
Old 24 June 2004, 09:52 AM
  #4  
rogp
Scooby Regular
Thread Starter
 
rogp's Avatar
 
Join Date: Mar 2003
Posts: 455
Likes: 0
Received 0 Likes on 0 Posts
Default

I think I understand the syntax of the REPLACE function but where in my code would I place it?

<input name="Email" type="text" value="<%response.write username%>@company.co.uk"%><%=REPLACE("<%response. write username%>@company.co.uk"," ",".")%> size="40" tabindex="4"><br><br></td>

This is the username variable being pulled from the cookie and an attempt to add the . to replace the <space> between firstname and surname.

Like this, it creates an error.

Can you tell I'm a noob?
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Darrell@Scoobyworx
Trader Announcements
26
30 January 2024 01:27 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
hardcoreimpreza
Computer & Technology Related
21
11 October 2015 03:40 PM
alcazar
Computer & Technology Related
2
29 September 2015 07:18 PM



Quick Reply: ASP Help - editing text string



All times are GMT +1. The time now is 10:12 PM.