torg Posted April 9, 2003 Posted April 9, 2003 It`s been said that converting string variables to numeric variables and vice versa is bad programming practice, and that option strict on should be used. Why is that? Quote
*Experts* Volte Posted April 9, 2003 *Experts* Posted April 9, 2003 http://www.xtremedotnettalk.com/showthread.php?s=&threadid=71107 ^ Look at the discussion there. Option Strict simply prevents implicit conversion between data-types. You can still convert from String to Integer by doing it like this:'Int -> String myString = Convert.ToString(myInt) 'String -> Int myInt = Integer.Parse(myString)But you can't do this:myInt = myString Quote
Phreak Posted April 9, 2003 Posted April 9, 2003 Option strict basically disallows any implicit conversions of data types. The reason for this, is that somewhere down the line (usually after you've already deployed the application), converting one type to another type might cause undesired results and hence, crashing your application. So with Option Strict On, you are not allowed to build your solution/project if you have implicit conversions. Try using CType(STRING, INT) or vice-versa, so you aren't implicitly converting data types. Quote If it works... don't worry, I'll fix it.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.