Because i am really new to vb i have always just bundled code into my main form. I am trying to tidy this up now and start using classes. But when should you use a class?
For example. Say we have a function thats called by a button.
this is more clutter to the main form, so would i add this to a class? or am i going about this all wrong?
If the answer is yes. Then im not quite sure how you call a class function.
How would i have this function in a class and be able to call it from formMain?
For example. Say we have a function thats called by a button.
VB.NET:
Private Function UrlIsValid(ByVal url As String) As Boolean
Dim is_valid As Boolean = False
If url.ToLower().StartsWith("www.") Then url = "http://" & url
Dim web_response As HttpWebResponse = Nothing
Try
Dim web_request As HttpWebRequest = _
HttpWebRequest.Create(url)
web_response = DirectCast(web_request.GetResponse(), HttpWebResponse)
Return True
Catch ex As Exception
Return False
Finally
If Not (web_response Is Nothing) Then web_response.Close()
End Try
End Function
this is more clutter to the main form, so would i add this to a class? or am i going about this all wrong?
If the answer is yes. Then im not quite sure how you call a class function.
How would i have this function in a class and be able to call it from formMain?