Solved

vbscript function to separate field into multiple variables

Posted on 2011-03-15
4
629 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Worked Beautifully!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
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.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now