mulliganmark Posted January 23, 2003 Posted January 23, 2003 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 Quote
Datahighway Posted January 23, 2003 Posted January 23, 2003 (edited) Hi mulliganmark in your Module you build a Function and return a string 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] Edited January 23, 2003 by Robby Quote
mulliganmark Posted January 24, 2003 Author Posted January 24, 2003 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 Quote
*Experts* Bucky Posted January 24, 2003 *Experts* Posted January 24, 2003 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. 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. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Experts* Volte Posted January 24, 2003 *Experts* Posted January 24, 2003 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.