Solved

vbscript function to separate field into multiple variables

Posted on 2011-03-15
4
631 Views
Last Modified: 2012-06-27
i have a form on my asp page for an email address

people are putting multiple addresses in this textbox either separated with a [space] [,] or a [;]

example: bob@yahoo.com;mary@aol.com
or
bob@yahoo.com mary@aol.com
or
bob@yahoo.com,mary@aol.com

i need a function that can separate these into two variables
then assign to session variables

session("email1")
session("email2")


0
Comment
Question by:rmardis
  • 2
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 35143905
Hi, try this.

Regards,

Rob.
strUserInput = "bob@yahoo.com;mary@aol.com"
SplitEmails strUserInput

Sub SplitEmails(strEmailString)
	arrAddresses = Array("")
	If InStr(strUserInput, " ") > 0 Then
		arrAddresses = Split(strUserInput, " ")
	ElseIf InStr(strUserInput, ";") > 0 Then
		arrAddresses = Split(strUserInput, ";")
	ElseIf InStr(strUserInput, ",") > 0 Then
		arrAddresses = Split(strUserInput, ",")
	End If
	If arrAddreses(0) <> "" Then
		For intEmail = 0 To UBound(arrAddresses)
			session("email" & intEmail + 1) = arrAddresses(intEmail)
		Next
	End If
End Sub

Open in new window

0
 

Author Comment

by:rmardis
ID: 35144037
The Line

session("email" & intEmail + 1) =

will this result in  session("email"1)

if so

who would i get it to result in session("email1")
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35144291
No, it should interpret as
session("email1") = "emailaddress1"
session("email2") = "emailaddress2"

As long as the session variables can be assigned that way....should work....
0
 

Author Closing Comment

by:rmardis
ID: 35206153
Worked Beautifully!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question