This is a rudimentary question as I am new to vb.net, so your patience is appreciated. I have created a method within a class and now I am trying to import that into my page.
The method looks like this
Public Shared Sub urlVars(ByVal langVar, ByVal countryVar)
Dim countryLanguage As String
countryLanguage = (HttpContext.Current.Request("URL"))
langVar = (Mid(countryLanguage, 2, 2))
countryVar = (Mid(countryLanguage, 5, 2))
End Sub
On the page I am trying to call that method into the page with this
Dim globalVars As url-parser = new url-parser(countryLanguage)
As you might of guessed this isn't working. Thanks for any help.
Loading
ShankeyPosted Aug 19, 2010, 5:53 AM
First of all you cant access shared method of a class using the object of that class. You can access directly using class name for e.g. 'url-parser.urlVars(new object,new object)' as in you case. For further help i created a website for you and i can access that method.
Code for "default.aspx.vb" is as bellow:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim globalVars = New url_parser()
url_parser.urlVars(New Object, New Object)
End Sub
End Class
Code for "url_parser.vb"
Imports Microsoft.VisualBasic
Public Class url_parser
Public Shared Sub urlVars(ByVal langVar, ByVal countryVar)
Dim countryLanguage As String
countryLanguage = (HttpContext.Current.Request("URL"))
langVar = (Mid(countryLanguage, 2, 2))
countryVar = (Mid(countryLanguage, 5, 2))
End Sub
End Class
Following is the application structure