Showing posts with label creating. Show all posts
Showing posts with label creating. Show all posts

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

Friday, March 16, 2012

Passing a variable to HTML

Hi,

I'm creating a control that displays the Previous and Next Pages. I get the
values I want but they don't display in the HTML Href tag. It just displays
blank. I declared the 2 variables PageBack and PageNext outside the sub but
that doesn't seem to work.
I tried using a session variable but I had to reload the page twice to get
the correct number.

<%@dotnet.itags.org. Control Language="VB" %>
<script runat="server">
Dim PageBack as String
Dim PageNext as String

Sub Page_Load(sender As Object, e As EventArgs)
Dim strPageName = System.IO.Path.GetFileName(Request.Path)
Dim PageName as String = strPageName
Dim PageNumber As String = Mid(PageName,5,3)
Dim BackPg as String = PageNumber - 1
Dim NextPg as String = PageNumber + 1
PageBack= Left(PageName,4)&"00"&BackPg &".aspx"
PageNext= Left(PageName,4)&"00"&NextPg &".aspx"
End Sub

</script>
<a href="http://links.10026.com/?link=<%# PageBack %>">Back</a><br>
<a href="http://links.10026.com/?link=<%# PageNext %>">Next</a
Thanks

--
Message posted via http://www.dotnetmonster.com<a href="http://links.10026.com/?link='<%# PageBack %>'">Back</a><br
Thanks. That still gives me an empty Href. I'm doing a response.write to
make sure there's a value in the variable and there is.

--
Message posted via http://www.dotnetmonster.com

Passing a variable to HTML

Hi,
I'm creating a control that displays the Previous and Next Pages. I get the
values I want but they don't display in the HTML Href tag. It just displays
blank. I declared the 2 variables PageBack and PageNext outside the sub but
that doesn't seem to work.
I tried using a session variable but I had to reload the page twice to get
the correct number.
<%@dotnet.itags.org. Control Language="VB" %>
<script runat="server">
Dim PageBack as String
Dim PageNext as String
Sub Page_Load(sender As Object, e As EventArgs)
Dim strPageName = System.IO.Path.GetFileName(Request.Path)
Dim PageName as String = strPageName
Dim PageNumber As String = Mid(PageName,5,3)
Dim BackPg as String = PageNumber - 1
Dim NextPg as String = PageNumber + 1
PageBack= Left(PageName,4)&"00"&BackPg &".aspx"
PageNext= Left(PageName,4)&"00"&NextPg &".aspx"
End Sub
</script>
<a href="http://links.10026.com/?link=<%# PageBack %>">Back</a><br>
<a href="http://links.10026.com/?link=<%# PageNext %>">Next</a>
Thanks
Message posted via http://www.webservertalk.com<a href="http://links.10026.com/?link='<%# PageBack %>'">Back</a><br>
Thanks. That still gives me an empty Href. I'm doing a response.write to
make sure there's a value in the variable and there is.
Message posted via http://www.webservertalk.com

Passing a variable to HTML tag

Hi,

I'm creating a control to get the next and back page name. When I try to pass that name to the href tag in the HTML, the link is empty and I'm not sure what's wrong. I've checked the values with response.write so I know that the values are there. I've also defined the PageBack and PageNext variables outside the sub.


<%@dotnet.itags.org. Control Language="VB" %>
<script runat="server">
Dim PageBack as String
Dim PageNext as String

Sub Page_Load(sender As Object, e As EventArgs)
Dim strPageName = System.IO.Path.GetFileName(Request.Path)
Dim PageNumStart as Integer = strPageName.Indexof("P") +2
Dim PageNumEnd as Integer = strPageName.Indexof(".")+1
Dim PageNum as String = Mid(strPageName,PageNumStart,PageNumEnd-PageNumStart)
PageBack=Left(strPageName,PageNumStart-1)&PageNum-1 &".aspx"
PageNext=Left(strPageName,PageNumStart-1)&PageNum+1 &".aspx"
End Sub

</script>
Back<br>
Next

I've also tried the href with just the double quotes: ="<%# PageBack %>"
ThanksYou need to call DataBind() at the end of your Page_Load.
Thanks so much. I normally do but forgot it here.

Passing an Array as a Property

I need some help with the syntax of creating a property, as i don't understand them very well.
I would like to use the following in a property:

SqlParameter [] param = new SqlParameter[3];

param[0] = new SqlParameter("@dotnet.itags.org.attend", SqlDbType.NVarChar, 3);
param[0].Value = this.TextBox1.Text;
.
.
.
the textboxes are also in another class (webform), so i'm not sure how can i use them as well.
If anybody has any suggestions, i'd really appreciate it.The syntax to create a property in a class is as follows:

1) create a private variable in the class to hold and return the value
2) create the Get & Set accessors for the private variable described in 1

Example:

This will create a "Customer Name" property to a class:


private string _customerName;

public string CustomerName
{
get
{
return _customerName;
}
set
{
_customerName=value;
}
}

Now with the syntax out of the way.. your specific question .. try this.. I am doing this from memory but it should work:


private SqlParameter[] _parameters;

public SqlParameter[] Parameters
{
get
{
return _parameters;
}
set
{
_parameters = value;
}
}

Now.. to use the property, you could do this:


MyObject obj = new MyObject();
obj.Parameters = new SqlParameter[2];
obj.Parameters[0] = new SqlParameter("@.par1","some value");
obj.Parameters[1] = new SqlParameter("@.par2","some value");

Hope this helps,