Saturday, March 24, 2012

passing a collection to a function

What I am doing is creating a web based email, using .net

I have finised the inbox, read, delete email etc..

Im in the process of making the "create email" or compose...

What the plan is, for people to be able to enter multiple "To:" "CC:" and "BCC:"

I have only done the "To:" field as yes, Atrax gave me the hint on how to split the emails with a ";" using split

What that did thou was place the emails into an array, which made it a pain to remove any blank emails which would cause an error...
I would always be working with strings, Below is the code that works with the "To" field

Dim arrTo(), strEmail As String
Dim j, intColCount, intEmptyColID As Integer
Dim colTo As ArrayList
Dim bolValidEmails, bolFoundInvalid As Boolean
'Dim objMsg As Object
'objMsg = Server.CreateOBject("JMail.Message")
'objMsg.Logging = true
'objMsg.Silent = true
'objMsg.From = Session("EmailAddress")
'\\\\\\\\\\\\\\\Splits the "To:" information into different emails - placing them into a collection for later use
colTo = New ArrayList
arrTo = strTo.Split(";")
For Each strEmail in arrTo
colTo.Add(trim(strEmail))
Next
'\\\\\\\\\\\\\\\Erases any empty emails out of the collection
bolValidEmails = False
bolFoundInvalid = False
intEmptyColID = -1
Do While bolValidEmails = False
For j = 0 To colTo.Count - 1
If bolFoundInvalid = False Then
If colTo(j) = "" Then
bolFoundInvalid = True
intEmptyColID = j
End If
End If
Next
If bolFoundInvalid = True Then
bolValidEmails = False
colTo.RemoveAt(intEmptyColID)
Else
bolValidEmails = True
End If
intEmptyColID = -1
bolFoundInvalid = False
Loop
'\\\\\\\\\\\\\\\Trims the Collection
colTo.TrimToSize()

What I want to do is, after I create the collection for any of the "to" "cc" and "bcc" is call that function and empty any blank emails, but I dont know how to pass the collection to the function and return the collection and continue on...

I was only using the
Dim strRandom As String
Dim objRand As New Misc
strRandom = objRand.GenerateRandNum()
objRand = Nothing
Response.Redirect("inbox.aspx?rnd=" & strRandom)

as an example of what i wanted to do as i couldn't remember the name after so many hours of programming =)...

I was asking can i use something like

Dim objChecker As New Misc
objRand.GenerateRandNum(ByRef collection name as ??)
objRand = Nothing
'continue with the rest of the email processing

do you have any code that passes a collection to a function like that? That I can look at, As I will need to be able to use the same function by multiple classes..(eg on the "reply", "Create email", "forward" class etc )

Thanks heaps

Hawk
ws abyss at infoyou can use a function with a parametere of collection as

1- dimension
private function myfunction(ByVal Arrto() As String)
or
private function myfunction(ByVal Arrto As String())

2- dimension
private function myfunction(ByVal Arrto(,) As String)
or
private function myfunction(ByVal Arrto As String(,))

Regards
Ather Ali Shaikh
"Hawk" <anonymous@.discussions.microsoft.com> wrote in message
news:13B899D4-3698-4E51-AC58-5FBE388D9C75@.microsoft.com...
> What I am doing is creating a web based email, using .net
> I have finised the inbox, read, delete email etc..
> Im in the process of making the "create email" or compose...
> What the plan is, for people to be able to enter multiple "To:" "CC:" and
"BCC:"
> I have only done the "To:" field as yes, Atrax gave me the hint on how to
split the emails with a ";" using split
> What that did thou was place the emails into an array, which made it a
pain to remove any blank emails which would cause an error...
> I would always be working with strings, Below is the code that works with
the "To" field
>
> Dim arrTo(), strEmail As String
> Dim j, intColCount, intEmptyColID As Integer
> Dim colTo As ArrayList
> Dim bolValidEmails, bolFoundInvalid As Boolean
> 'Dim objMsg As Object
> 'objMsg = Server.CreateOBject("JMail.Message")
> 'objMsg.Logging = true
> 'objMsg.Silent = true
> 'objMsg.From = Session("EmailAddress")
> '\\\\\\\\\\\\\\\Splits the "To:" information into different
emails - placing them into a collection for later use
> colTo = New ArrayList
> arrTo = strTo.Split(";")
> For Each strEmail in arrTo
> colTo.Add(trim(strEmail))
> Next
> '\\\\\\\\\\\\\\\Erases any empty emails out of the collection
> bolValidEmails = False
> bolFoundInvalid = False
> intEmptyColID = -1
> Do While bolValidEmails = False
> For j = 0 To colTo.Count - 1
> If bolFoundInvalid = False Then
> If colTo(j) = "" Then
> bolFoundInvalid = True
> intEmptyColID = j
> End If
> End If
> Next
> If bolFoundInvalid = True Then
> bolValidEmails = False
> colTo.RemoveAt(intEmptyColID)
> Else
> bolValidEmails = True
> End If
> intEmptyColID = -1
> bolFoundInvalid = False
> Loop
> '\\\\\\\\\\\\\\\Trims the Collection
> colTo.TrimToSize()
>
> What I want to do is, after I create the collection for any of the "to"
"cc" and "bcc" is call that function and empty any blank emails, but I dont
know how to pass the collection to the function and return the collection
and continue on...
> I was only using the
> Dim strRandom As String
> Dim objRand As New Misc
> strRandom = objRand.GenerateRandNum()
> objRand = Nothing
> Response.Redirect("inbox.aspx?rnd=" & strRandom)
> as an example of what i wanted to do as i couldn't remember the name after
so many hours of programming =)...
> I was asking can i use something like
> Dim objChecker As New Misc
> objRand.GenerateRandNum(ByRef collection name as ??)
> objRand = Nothing
> 'continue with the rest of the email processing
>
> do you have any code that passes a collection to a function like that?
That I can look at, As I will need to be able to use the same function by
multiple classes..(eg on the "reply", "Create email", "forward" class etc )
> Thanks heaps
> Hawk
> ws abyss at info

0 comments:

Post a Comment