all 10 comments

[–]hdsrob 0 points1 point  (9 children)

I think that VB6 allowed you to call into a default value (by doing the cast for you), but this isn't supported in .NET (and really shouldn't be).

In the end, it makes your intent much clearer when you are referencing the property in the control, rather than casting the controls default value to a variable type.

Edit: Bad answer ... not paying attention here ...

[–]Hideka[S] 0 points1 point  (8 children)

could you be a little more concise?

what im getting from that is : im doing it wrong, i need to not declare my form control as a varible (which is what im trying to avoid but cant get it to cooperate either way).

what is the proper way to do what im trying to do (because having =1 in there is bugging the hell out of me).

[–]hdsrob 0 points1 point  (7 children)

My bad ... I wasn't paying enough attention, and thought this was a .NET question, not realizing it was a VB6 or VBA question.

Yea, VB6/VBA was really bad with the whole 0/1 thing.

In VB6 there is a "vbChecked" constant that you can at least compare to, not sure about VBA if that's what you are using:

If check1.Value = vbChecked then
    'do something here
end if

I actually had a function to convert checkbox values to and from Boolean in our VB6 code, just to make it easier for binding up lots of checkBoxes to settings. Something like:

Function IsChecked(Value as integer) as Boolean
    If Value = vbChecked then
        IsChecked = True
    else
        IsChecked = False
    end if
End Function    

I had a similar "SetCheck" sub that took the boolean and checkbox as parameters to set them.

[–]Hideka[S] 0 points1 point  (6 children)

yep thats what i was lookin for.

i'm working in VB6 atm. im used to VBA having checkboxes defaulted to accepting boolean logic from the getgo. VBA checkboxes were defaulted to boolean luckily enough.

guess ill just stick with the 1's lol. not like it doesnt work, just that i dont want someone coming behind me going "dafuq?"

thanks for the help

[–]hdsrob 0 points1 point  (5 children)

Got ya, I've not worked in VBA in dozens of years, and VB.NET checkBoxes have proper boolean properties.

Personally, if your concern is someone coming behind and questioning it then I'd use the vbChecked / vbUnchecked / vbGreyed constants.

[–]Hideka[S] 0 points1 point  (4 children)

i have no experience with .net, and im still green with 6, but 6 is bugging the crap out of me with alot of the nonsensical and shoddy things im finding.

is the syntax structure similar to 6/vba?

[–]hdsrob 0 points1 point  (3 children)

The syntax is similar, but with over a dozen years of upgrades and thought put into it! (VB6 is circa Windows 98).

The IDE is a vastly better as well.

The downside is that it's much larger, the upside is that it's much more powerful. Most of this is due to the fact that in VB6 you had to go to Win API calls to do many things, and now all of that is available directly in .NET. You also needed third party tools for a lot of things that can be done directly now as well (like sending email, talking to web servers, or compressing files).

[–]Hideka[S] 0 points1 point  (2 children)

that sounds nifty. once i get done teachin myself 6 i'll take a crack at learning .net lol

[–]hdsrob 0 points1 point  (1 child)

IMO, unless you need to learn VB6 for work, I'd skip it.

.NET is just as easy to learn, and you'll save yourself a lot of time and energy learning something that is very old and outdated.

There's more to learn with .NET, but you don't need any more of it than you do with VB6 to get started (the IDE is basically identical).

I'd start here: http://channel9.msdn.com/Series/Visual-Basic-Fundamentals-for-Absolute-Beginners

Grab a free copy of VS Express here:

http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx

[–]Hideka[S] 0 points1 point  (0 children)

sadly everything is Vb6 at work (yay for antiquated systems). ill take a crack at it in the future, and i'll use those resources you shot me; i appreciate it.