Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vbscript function to separate field into multiple variables

Posted on 2011-03-15
4
Medium Priority
?
639 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

877 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