triplemaya
Member
- Joined
- Aug 27, 2006
- Messages
- 15
- Programming Experience
- Beginner
My program is crashing because of an error "conversion from string "" to type integer is not valid"
The program gets a number of values from text boxes, so I'm assuming this is where the problem is, and I'm presuming it is when CInt is called on an empty string.
I've written a little function MyCInt which should solve the problem.
Public function MyCInt(ByVal IText AsString) As Integer
If iText = "" Then Return 0
Return CInt (iText)
end function
The trouble is, it is not seen outside the class in which I declare it. Do I need to have this be a class? I need a quick and simple way of trying this out, especially since I don't know if it is going to work. Is there something like a public static function which can be seen globally?
This is I am sure a really basic question, and my apologies for not knowing how to look this up. This code has been delivered 'finished', it is live on a site, and I am supposed to be marketing it not fixing it! I have googled about a bit, but I don't know what to look for.
Sorry if this is in the wrong place, I didn't know where else to put it.
The program gets a number of values from text boxes, so I'm assuming this is where the problem is, and I'm presuming it is when CInt is called on an empty string.
I've written a little function MyCInt which should solve the problem.
Public function MyCInt(ByVal IText AsString) As Integer
If iText = "" Then Return 0
Return CInt (iText)
end function
The trouble is, it is not seen outside the class in which I declare it. Do I need to have this be a class? I need a quick and simple way of trying this out, especially since I don't know if it is going to work. Is there something like a public static function which can be seen globally?
This is I am sure a really basic question, and my apologies for not knowing how to look this up. This code has been delivered 'finished', it is live on a site, and I am supposed to be marketing it not fixing it! I have googled about a bit, but I don't know what to look for.
Sorry if this is in the wrong place, I didn't know where else to put it.