Print Page | Close Window

ASP 3.0 Urgent Help Required Please

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=24966
Printed Date: 28 March 2026 at 7:50pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP 3.0 Urgent Help Required Please
Posted By: mhanif
Subject: ASP 3.0 Urgent Help Required Please
Date Posted: 08 December 2007 at 8:37am
I really need it ASAP. Please help me.
 
 
<%
sentence = "My Mail Has Been Deleted"
%>
 
Now i want to make three pieces of this sentence and... want it like this
 
<%
variable1 = "MY"
variable2 = "Mail"
Variable3 = "Has Been Deleted"
%>
 
Note:
All the sentences, i want to edit contains this word "Mail" and i want to break the sentence from where "Mail" Starts and third pieace of the sentence should start with where the "Mail" ends.
 
One more example (just to explain clearly what i want)
 
<%
setence "His Mail is Rubbish"
%>
 
It should be like this
 
<%
variable1 = "His"
variable2 = "Mail"
variable3 = "Is Rubbish"
%>
 
Please help. Thank you.
 
 



Replies:
Posted By: jamie.townsend
Date Posted: 08 December 2007 at 8:45am
Very simple to do with asp. You should use the split function.
 
There is a tutorial for this here: http://www.w3schools.com/vbscript/func_split.asp - http://www.w3schools.com/vbscript/func_split.asp


Posted By: mhanif
Date Posted: 08 December 2007 at 8:49am
Thanks, yes its very simple but the thing is, i never worked on this function. ok i am checking the site you have just given,
 
If anyone has any idea please post.
 
Thanks jamie, so nice of you.


Posted By: jamie.townsend
Date Posted: 08 December 2007 at 8:55am

If you are not sure about the length of your sentence then you can use something like this.


Dim SplitWords
Dim Sentence

Sentence = "This is your sentence"
SplitWords = Split(Sentence, " ")

Dim i
For i = 0 to Ubound(SplitWords)
Response.Write SplitWords(i) & "<BR>"
Next


Posted By: mhanif
Date Posted: 08 December 2007 at 9:02am
this is the result,
 
This
is
your
sentence
 
can u please tell me how do i add "This" in variable1 "is in variable2 and so on
 
 


Posted By: jamie.townsend
Date Posted: 08 December 2007 at 9:04am
Is there going to be a set amount of variables or will it depend on the length ?
Sorry if I am not clear.
 
Is there going to be 3 variables and thats it or is it possible there will be more ?


Posted By: mhanif
Date Posted: 08 December 2007 at 9:06am
i think i have done it,, if i succeed, i will post it here okay friend...
 
Thanks once again, it would'nt be easier without ur help (that quickly) Smile


Posted By: jamie.townsend
Date Posted: 08 December 2007 at 9:08am
Nice one !


Posted By: mhanif
Date Posted: 08 December 2007 at 9:10am
See it worked like this....
 
<%
Sentence = "This is sentence"
SplitWords = Split(Sentence, " ")
variable1 = SplitWords(0)
variable2 = SplitWords(1)
variable3 = SplitWords(2)
response.write variable1 & "<br />"
response.write variable2 & "<br />"
response.write variable3 & "<br />"
%>
 
so now i will be able to add one sentence in database but into pieces... and this is what i wanted... i think the work is done, i dont know if anything goes wrong later :) anyways....  Smile


Posted By: jamie.townsend
Date Posted: 08 December 2007 at 9:12am
Make sure your variable3 = SplitWords(2)
 
Glad I could help you getting this working.
Let me know if you need anymore help :)


Posted By: mhanif
Date Posted: 08 December 2007 at 9:13am

yes man i will need your help, soon i will reply my post here, once i go ahead with my work :)



Posted By: mhanif
Date Posted: 08 December 2007 at 9:15am

see, i just got stuck Big%20smile

can u tell me something which can help me with this... see what i want is
 
variable1 = "First word of sentence"
variable2 = "second word of sentence"
 
and i want variable3 = "the remaining part of the sentence" no matter 100 words are remaining.
 
 
Edited:(


Posted By: jamie.townsend
Date Posted: 08 December 2007 at 9:16am
Good luck in your coding travels Smile


Posted By: mhanif
Date Posted: 08 December 2007 at 9:22am
Ok, That is solved too i think, thanks man........  hope to talk to you soon.


Posted By: jamie.townsend
Date Posted: 08 December 2007 at 9:25am
Perhaps something like this:

<%
Dim SplitWords
Dim Sentence
Dim Variable1, Variable2, Variable3

Sentence = "This is your sentence"
SplitWords = Split(Sentence, " ")
Variable1 = SplitWords(0)
Variable2 = SplitWords(1)

Dim i
For i = 2 to Ubound(SplitWords)
Variable3 = Variable3 & " " & SplitWords(i)
Next
response.write(Variable1 & "<br />")
response.write(Variable2 & "<br />")
response.write(Variable3 & "<br />")
%>


Posted By: mhanif
Date Posted: 08 December 2007 at 9:34am
Great Smile 


Posted By: jamie.townsend
Date Posted: 08 December 2007 at 9:41am
Hope it works ok.


Posted By: mhanif
Date Posted: 11 December 2007 at 8:11am
okay ;) it worked and every thing is fine now. As i said it wouldnt be that easy without ur quick help, that day u replied just after 5 minutes and that made me go ahead with project very quickly ...
 
so thanks alot.
 
actually wat i was trying to do is that i had database with one field which had three a sentence and i wanted to make three pieces of it and add it into three different fields , so after spliting , i added them into different fields and now my work is done.
 
Once again, thanks alot.....     take care...


Posted By: jamie.townsend
Date Posted: 11 December 2007 at 9:44am
You are very welcome :D



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net