If this is the textbox's LostFocus event why would you need to ask for the sender object?
And you should unbox it with {CType(sender, Textbox).Text} anyway.
The Right function returns the number of pixels from the right edge of the control and the left edge of it's container's client area and takes no parameters as it is a read only property, how does that work here?
I would use Regex as it will force them to fix it or not be able to continue:
Imports System.Text.RegularExpress
...
Pri
Dim m As Match = Regex.Match(txtbox.Text, "\w*.xml")
If Not m.Success Then
MessageBox.Show("Format must be ""myxmlfile.xml""")
txtbox.Select()
End If
End Sub
Main Topics
Browse All Topics





by: JackOfPHPosted on 2009-11-03 at 20:18:57ID: 25736374
Put this code in the lost focus event of the textbox
Dim txtbox as textbox = sender
If Not Right(txtbox.text,4) = ".xls" then
txtbox.text &= ".xls"
End if
Cheers,