View Single Post
  #5 (permalink)  
Old March 2nd, 2008, 02:33 PM
dparsons dparsons is offline
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Upendra and Ankur have alluded to this but you should definately pick up a book about programming with Visual Basic. To build on what Ankur said with regard to classes, this is where you will find alot of programmers place code that they call from various places throughout an application.

For example, let's say that in your application once the user has clicked a button you check that several textboxes do not contain an empty string. You could write an if statement for each of the textboxes:

If textbox1.Text = "" then 'do something
If textbox2.Text = "" then 'do something

Or you could create a class that does this for you:

Public Class foo
    Public Shared Function isValid(ByVal value As String) As Boolean
        If value = "" Then
            Return False
            Return True
        End If
    End Function
End Class

so now to check the value of each of your textboxes you would make a call similar to this:

if Not foo.isValid(textbox1.Text) then 'do something
if Not foo.isValid(textbox2.Text) then 'do something

Granted, this is an overly simplistic example but it demonstrates the methodology very well because now, through out your entire application, everytime you need to check if a textbox contains a value you can call this central class 'foo' which will do the evaluation for you; your application simply needs to handle the Boolean value coming back from the function.

In so far as not redrawing the form, that depends. If the form elements are the same for each form then you could add a combo box to the form that could change the 'mode' of the form. In your case the combo box would contain: Math, Spelling, and Word so, theoretically, when the user clicks the 'Complete' button your event handler could look something like this:

Protected Sub btn_Click(ByVal sender As Object, ByVal e As eventArgs) Handles btn.Click
     Select Case cmb.Text
         Case "Math"
         Case "Spelling"
         Case Else
     End Select
End Sub

This should be enough material for you to continue working on your app but I emplore you to purchase a book that can address not merely HOW to do something but WHY you should be doing it.

Wrox has many books that address this topic:

From that list I would suggest:

Alternatively you can purchase a subscription to Wrox's online library which gives you access to a large portion of the Wrox Collection (the book mentioned above is in there as well): it costs 49.99 for a quarter or 175.00 for an entire year. You can get more information regrading this service here:


================================================== =========
Read this if you want to know how to get a correct reply for your question:
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote