11 replies
by rrv
It is very much possible to pass data between textboxes in different forms.
example
form1.text1.text=form2.text1.text
in a text box if you want to check if valid date is entered, you have to write your own routine. a better way is to use amasked edit or more/best way is to use the DTPicker control. This comes in Microsoft Windows Common Controls-2.6.0
In textbox use this logic
if len(text1.text)=10 then
if mid$(text1.text,1,3)="/" and mid$(text1.text,1,6)="/" then 'for dd/mm/yyyy format checking
'find => val(mid$(text1.text,4,2))
if this value is like 1,3,5... these months have 31 days. check that
similarly find if it is leap year. then check for 29/28 days in february.
endif
endif
For all these i'd suggest you to use DTPicker control which is shipped with VB.
All the best.
Raja venkatesh R
rrv@hotvoice.com
by thedon11550
by shmaltz
use the isdate function to validate for a valid date.
to pass from form to form you can either do:
form1.textbox1.text=form2.textbox1.text
or:
create public variables in you program that will hold the data, and when someone enters the data in the first form make sure that the variables get updated.
or:
use a database (it does not have to be a real database it can be a text file that has like field names in the begining of the line and then an "=" before the data, and use the file object to access the text file) that gets updated each time you put in a value in the first form and the second form will take the values from the database.
by thedon11550
by cedric king
by thedon11550
by cyberjack154
I would suggest that you use:
Dim variable as variable type
in teh general declarations section of teh code. That will make it public. Which means it can be read by all forms and sub procedures.
by thedon11550
by gbworld
For the date use isDate():
http://msdn.microsoft.com/library/default.asp?URL=/library/wcedoc/vbce/function_40.htm
You can do further checks on the date, depending on your needs, but this will check if it is a valid date (meaning 17/86/101 would be rejected).
In Visual Basic, forms are objects, as are the text boxes that sit on them. To pass information, you need to work from the form that has focus (not really, but it is easier) and pull or push data, as necessary. After you instantiate a form, you can pull, like this:
thisform.text1.text = otherform.text1.text
The same holds true for any public property of the form(s) in your application. If you think of forms as objects (like classes), this all starts to make sense. You alsostart to understand the reason for limiting scope of the variables in your applications.
GB
by thedon11550
by thedon11550
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending