Hi all,
I have encountered this error Unable to cast object of type 'System.String' to type 'System.IFormatProvider'. when i try to use a "if" statement to check for a certain string format in a the text of a string.
heres the code i have done:
I have encountered this error Unable to cast object of type 'System.String' to type 'System.IFormatProvider'. when i try to use a "if" statement to check for a certain string format in a the text of a string.
heres the code i have done:
VB.NET:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
Dim unit As String = txtUnit.Text
Dim MyString As String
If (MyString = unit.ToString("'#'##-##") = False) Then
MsgBox("Unit num should be in this format, " & "#00-00""")
Exit Sub
Else
'Update data to database
End If
End Sub