|
-
Feb 1st, 2003, 04:50 PM
#1
Thread Starter
New Member
What this code mean ???
Private Sub txtName_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFirstName.Validating, txtLastName.Validating
If CType(sender, TextBox).Text = "" Then
MessageBox.Show("You must enter a first and last name.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
e.Cancel = True
End If
End Sub
I write this code from the book and it's work but I don't know what I wrote??
What is ...
1 - CType mean?
2 - Sender mean?
3 - TextBox mean? (My TextBox name is txtFirstName why I use TextBox not txtFirstName?)
Thanks all,
-
Feb 1st, 2003, 05:00 PM
#2
yay gay
CType() converts the first argument to the type of data specified by the second argument
\m/  \m/
-
Feb 1st, 2003, 07:49 PM
#3
Re: What this code mean ???
Originally posted by Roomi7
Private Sub txtName_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFirstName.Validating, txtLastName.Validating
If CType(sender, TextBox).Text = "" Then
MessageBox.Show("You must enter a first and last name.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
e.Cancel = True
End If
End Sub
I write this code from the book and it's work but I don't know what I wrote??
What is ...
1 - CType mean?
2 - Sender mean?
3 - TextBox mean? (My TextBox name is txtFirstName why I use TextBox not txtFirstName?)
Thanks all,
question 1 was answered 
3 was answered too: The second argument of ctype gets the type of the object, which is TextBox. That's why you use that
2 -> sender is the object that has fired this event. So if txtFirstName fired a Validating event the sender object would be txtFirstName. If txtLastName fired the event, then sender would be txtLastName.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 1st, 2003, 08:17 PM
#4
Sleep mode
Originally posted by Roomi7
Private Sub txtName_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFirstName.Validating, txtLastName.Validating
If CType(sender, TextBox).Text = "" Then
MessageBox.Show("You must enter a first and last name.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
e.Cancel = True
End If
End Sub
I write this code from the book and it's work but I don't know what I wrote??
What is ...
1 - CType mean?
2 - Sender mean?
3 - TextBox mean? (My TextBox name is txtFirstName why I use TextBox not txtFirstName?)
Thanks all,
the object that raises the event is the sender .In your case , I think it's textbox object .
your now converting the expression into TextBox data type object "text".
this example explain it more :
VB Code:
Dim dic As Decimal = 1.002
Dim byt As Byte
byt = CType(dic, Byte)
MsgBox(byt.ToString)
-
Feb 1st, 2003, 08:17 PM
#5
Sleep mode
too late......
-
Feb 2nd, 2003, 01:31 AM
#6
Thread Starter
New Member
Thanks alot now it's clear to me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|