Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to put Sub functions?
Message
From
23/10/2003 17:27:28
 
 
To
23/10/2003 17:20:25
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00841315
Message ID:
00841859
Views:
24
This message has been marked as a message which has helped to the initial question of the thread.
Michel,

Are you trying to make your function static or whatever it's called in VB ... and if so, you haven't done that, so you need to instantiate your class first. Plus, you've mad the AddSpeaker() method private, so there's no way you're gonna be able to access it. It needs to be public.

~~Bonnie


>>I'm a C#'er so not 100% sure of the VB syntax. But, the fact of the method being static isn't what makes it callable from both pages, I guess I kinda misstated that. Making it static allows you to call it without instanciating the class. So, in your code you can just do...
>>
>>MyResult = WebCommon.MyStaticMethod(Whatever)
>>
>>without having to createobj, or whatever you do to instanciate in VB.Net.
>>
>>If the webcommon class is in the same project and the same namespace as your aspx pages it should be callable. If you want to put your webcommon in another project you would have to add a reference to that project from your webpage's project to use it.
>
>I created a class named Function.vb. It is in the same project. I put the class in it. It's like this:
>
>
>Public Class _Function
>
>
>   ' Add a speaker
>   ' expN1 Speaker ID
>   ' expL1 If the speaker picture is available
>   ' expC1 Speaker name
>   ' expM1 Speaker bio
>   Private Function AddSpeaker(ByVal tnSpeakerID, ByVal tlPicture, ByVal tcName, ByVal tmBio)
>      Dim lcHtml As String
>      Dim lcUniversalThread As String
>
>      lcHtml = ""
>
>      ' Universal Thread url
>      lcUniversalThread = "http://www.levelextreme.com/"
>
>      If tnSpeakerID > 0 Then
>         lcHtml = lcHtml + "<TABLE CELLSPACING=0 CELLPADDING=0>"
>         lcHtml = lcHtml + "<TR VALIGN=TOP>"
>         lcHtml = lcHtml + "<TD ALIGN=CENTER WIDTH=90>"
>         If tlPicture Then
>            lcHtml = lcHtml + "<IMG SRC=" + lcUniversalThread + _
>             "Photo/" + tnSpeakerID.ToString().PadLeft(6, "0") + ".jpg>"
>         Else
>            lcHtml = lcHtml + "<IMG SRC=" + lcUniversalThread + "Photo/PictureNotAvailable.jpg>"
>         End If
>         lcHtml = lcHtml + "<TD WIDTH=4>"
>         lcHtml = lcHtml + "<TD>"
>         lcHtml = lcHtml + tmBio
>         lcHtml = lcHtml + "</TABLE>"
>      End If
>      lcHtml = lcHtml + "<P>"
>      Return lcHtml
>   End Function
>
>
>End Class
>
>
>In the ASPX files, I remove the Sub function AddSpeaker(). Now, wherever AddSpeaker() is present, I see that we have a problem. So, I put the line like this:
>
>
>            ' Speaker 1
>            lcHtml = lcHtml + Function.AddSpeaker(lnSpeaker1, _
>             loData.Tables("Temp").Rows(lnCompteur)("SpeakerPicture1"), _
>             loData.Tables("Temp").Rows(lnCompteur)("Speaker1"), _
>             loData.Tables("Temp").Rows(lnCompteur)("SpeakerBio1"))
>
>
>It doesn't work as we have an unknown reference.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform