Solved

vbscript function to separate field into multiple variables

Posted on 2011-03-15
4
633 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help Creating a Powershell script 8 95
Powershell Split 18 42
PHP $_POST vs asp request 4 56
Macro to open folder and copy data from all excel files 10 73
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The viewer will learn how to dynamically set the form action using jQuery.
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 …

734 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