String Manipulation

Results 1 to 4 of 4

Thread: String Manipulation

  1. #1 Guest

    Default String Manipulation

    I need help with some text I am passing from a form. It is an address and I want to format it to look like an address. So basically I want to add html <BR> tags to the end of each line. I can&#039t figure out how to do it. Please help!!

  2. #2
    mark Guest

    Default RE: String Manipulation

    When you submit the form and do your <BR>myaddress = request.form("myaddress")<BR><BR>Now you can do a couple of things:<BR>1. You can do this command<BR>Response.write Replace(myaddress,vbcrlf,"<BR>")<BR>Which will go through &#039myaddress&#039 and look for a carriage return and replace it with the html tag "<BR>".<BR>2. Or you could try to separate myaddress into the different parts like address, city, state, zip, etc.<BR>You might use Instr(myaddress,vbcrlf), which will return the position of the next carriage return in the string &#039myaddress&#039<BR>

  3. #3 Guest

    Default RE: String Manipulation

    Thanks for your help, but I apologize I am still unclear. I tried the first option (because it seemed the easiest) it really is doing nothing to the address. I created a sub that carried out that statement and then I called it where I wanted to and it still placed the entire string on one line, except when it ran out of room. Is the fix you gave me, taking the string and then adding the break at the end of the string? The other way you said to find the position of the next carriage return, what then would I do?

  4. #4
    mark Guest

    Default RE: String Manipulation

    Now that I&#039m thinking about this problem you&#039re having, I&#039m wondering if you have considered using seperate fields for address, city, state, country, zip, etc. ??<BR><BR>It would be a lot easier for you to control the user input.<BR><BR>Anyway, here&#039s some of my further explanation about my previous reply:<BR>The first option takes the entire string and replaces all the carriage returns (vbcrlf&#039s) with "<BR>". I&#039m not sure why this isn&#039t working properly.<BR><BR>The second option you could use in the following way:<BR><BR>&#039Get the field data from the form.<BR>user_address = Request.Form("user_address")<BR><BR>&#039Now split the variable up<BR>start_pos = 0 &#039Start at the beginning<BR>end_pos = Instr(start_pos, user_address, vbcrlf) &#039Return the position of the next carriage return<BR>street_address = Mid(user_address, start_pos, end_pos - 1) &#039Get the value of the string between the start position and end position (the -1 is so that we don&#039t get the carriage return included in the string)<BR><BR>&#039Do the others in the same fashion<BR>start_pos = end_pos +1<BR>end_pos = Instr(start_pos, user_address, vbcrlf)<BR>city_state = Mid(user_address, start_pos, end_pos -1)<BR><BR>If you have any further questions, email me at

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts