Colleagues,
It's been awhile since I worked in VB last time (~14 years), and came back to it (now in .NET "incarnation") just now.
I forgot many simple things about VB. I could find some on the MS's website, but not all.
And - alas! - my access to the development environment is heavily restricted (company's policies), and I cannot just write some quick-n-dirty sample code and try it in VS 2012 IDE.
So, my questions here might look stupid - my apologies, please bear with me.
To the matter at hands.
One of the things that I can't remember, neither find in the MS Docs website is what subject line says.
Say, you are writing a function, and the parameters' data types are set, e.g.
and what happens if the calling code passes argument of incorrect data type? Say, NULL/Nothing instead of a String?
System will throw it's error message, right?
So, to prevent that, I want to first verify if that parameter is indeed of type String.
Will the following code do that?
Or it will err and throw error message box on its own before reaching that If?
TIA!
Regards,
Ilya
It's been awhile since I worked in VB last time (~14 years), and came back to it (now in .NET "incarnation") just now.
I forgot many simple things about VB. I could find some on the MS's website, but not all.
And - alas! - my access to the development environment is heavily restricted (company's policies), and I cannot just write some quick-n-dirty sample code and try it in VS 2012 IDE.
So, my questions here might look stupid - my apologies, please bear with me.
To the matter at hands.
One of the things that I can't remember, neither find in the MS Docs website is what subject line says.
Say, you are writing a function, and the parameters' data types are set, e.g.
Code:
Function MyFunc(ByVal cStr As String, ByVal iLen As Integer)
System will throw it's error message, right?
So, to prevent that, I want to first verify if that parameter is indeed of type String.
Will the following code do that?
Code:
Function MyFunc(ByVal cStr As String, ByVal iLen As Integer) As String
If cStr.IsNullOrEmpty() Then
MsgBox("Invalid parameter passed: cStr must not be NULL or empty", 16, "Code Error")
Return Space(0)
End If
TIA!
Regards,
Ilya