Modules??

mulliganmark

Newcomer
Joined
Jan 15, 2003
Messages
5
I have created a form with 'x' of textboxes on it, that have mulitple validation rules. So i Thought that i will create a module to do the checking & validation.

But how do i link the textbox of the form to the module.

PS this is my first time at coding
 
Hi mulliganmark

in your Module you build a Function and return a string
Visual Basic:
see my Code sample

Public Function myTextBox()
        Dim _string As String
        _string = " Here comes a text"
        Return _string
    End Function

'------------------------------------------
This write in your Form1 Class
TextBox1.Text = Module1.myTextBox

[edit]changed < > for [ ] [/edit]
 
Last edited by a moderator:
I think that explained it wrong.

What i want to do is pass the textbox1 (form1) value to the module1.
It will then validated it by saying ie "Please note you have to enter a value"

I think another way is. That you have 3 textboxes on form1, these boxes perform a calculation ie box1 + box2 = box3. Therefore in the module it check to see if there is a value in box1 & box2 if not returnd and error message?

I hope this is better
 
You can create a function that returns a Boolean value to do
your validation. Return False if it isn't validated, and True if it's okay.

Visual Basic:
Public Function ValidateBox(txt As TextBox) As Boolean

' in here, check the value of txt.Text and if it is okay, then:
' Return True
'
' Otherwise, you want to:
' Return False

End Function

Then, in your form code, just pass the textbox to the sub, check
the Boolean value that is returned, and show a message if it's
false. You can create functions that accept more than one textbox
in the arguments, if you want.
 
Just a suggestion; If you want to have user-friendly error validation,
look in Tutor's Corner (or was it Code Library?) for divil's tutorial
about using the ErrorProvider component. It allows for non-intrusive,
yet effective error notification.
 
Back
Top