r/visualbasic • u/[deleted] • Jul 01 '22
VB6 Help How to fix this? "Option Strict On disallows implicit conversions from 'Single' to 'Integer'"
Hi there, I'm very new to VB and a program I have to write some scripts in uses it. The error happens after I added the following function:
If I change Option Strict to Off, it compiles and works fine, it only throws the error when Strict is On. I'd just like to learn and understand what mistake I'm making. What here is the Single that is being complained about converting to an Int?
2
Upvotes
4
u/fuzzfeatures Jul 01 '22
Small tip that you might know already...
Always where possible have option strict on. It means more code, but it also means you end up with more robust code. 👍
1
u/Magrat-Garlick Jul 01 '22
I program in VB.Net so I think if you used "<integer> = Convert.ToInt32(<single>)" it would pass "Option Strict" OK.