Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Array looping

Reply
Thread Tools

Array looping

 
 
David C
Guest
Posts: n/a
 
      07-19-2009
I am getting an exception error whenever the code below goes into the
For...Next loop. Can anyone spot what I am doing wrong? Also, the
txtEmailTo.Text has email addresses and if more than 1 they are separated by
a semicolon. Thanks.
David

Dim mm As New MailMessage()

'(2) Assign the MailMessage To and From properties
'Note that mm.To is a collection so that multiple people can be
emailed.
If InStr(txtEmailTo.Text, ";") > 0 Then
'Dim strEmailTo() = ""
Dim strTo As String
For Each strTo In Split(";", txtEmailTo.Text)
mm.To.Add(strTo)
Next
Else
mm.To.Add(txtEmailTo.Text)
End If


 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      07-19-2009
David C wrote:
> I am getting an exception error whenever the code below goes into the
> For...Next loop. Can anyone spot what I am doing wrong? Also, the
> txtEmailTo.Text has email addresses and if more than 1 they are separated by
> a semicolon. Thanks.
> David
>
> Dim mm As New MailMessage()
>
> '(2) Assign the MailMessage To and From properties
> 'Note that mm.To is a collection so that multiple people can be
> emailed.
> If InStr(txtEmailTo.Text, ";") > 0 Then
> 'Dim strEmailTo() = ""
> Dim strTo As String
> For Each strTo In Split(";", txtEmailTo.Text)
> mm.To.Add(strTo)
> Next
> Else
> mm.To.Add(txtEmailTo.Text)
> End If
>
>


You should be using:

for each strTo in Split(txtEmailTo.Text, ";")

--
Mike
 
Reply With Quote
 
 
 
 
David C
Guest
Posts: n/a
 
      07-19-2009
Thanks Mike. Simple mistake.
David
"Family Tree Mike" <> wrote in message
news:%...
> David C wrote:
>> I am getting an exception error whenever the code below goes into the
>> For...Next loop. Can anyone spot what I am doing wrong? Also, the
>> txtEmailTo.Text has email addresses and if more than 1 they are separated
>> by a semicolon. Thanks.
>> David
>>
>> Dim mm As New MailMessage()
>>
>> '(2) Assign the MailMessage To and From properties
>> 'Note that mm.To is a collection so that multiple people can
>> be emailed.
>> If InStr(txtEmailTo.Text, ";") > 0 Then
>> 'Dim strEmailTo() = ""
>> Dim strTo As String
>> For Each strTo In Split(";", txtEmailTo.Text)
>> mm.To.Add(strTo)
>> Next
>> Else
>> mm.To.Add(txtEmailTo.Text)
>> End If
>>
>>

>
> You should be using:
>
> for each strTo in Split(txtEmailTo.Text, ";")
>
> --
> Mike



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping in array vs looping in a dic giuseppe.amatulli@gmail.com Python 5 09-20-2012 11:58 PM
quickly looping over a 2D array? Martin Python 9 07-27-2009 04:11 PM
Looping through tw-dimensional array neptune6644@gmail.com ASP General 2 12-01-2006 02:17 AM
looping through array to find next matching element Psybar Phreak Java 1 10-06-2003 06:01 PM
Method not recognizing PAREN when looping through character array Curts Java 1 08-21-2003 10:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57