Declaring Variables and Assigning Values - 05
- Posted: Nov 21, 2011 at 9:24 AM
- 37,012 Views
- 4 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
In this lesson we start adding Visual Basic syntax to your vocabulary by talking about one of the fundamental building blocks: data types and variables. Beyond the basics topics such as naming conventions and explicit versus implicit data type conversions are discussed.
Download the source code for Declaring Variables and Assigning Values
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
Disclosure: I know absolutely NOTHING about programming . . . which is why I'm watching these videos, which I'm really enjoying - so far! That said, I don't understand why one would use the CInt thingy (technical term) in line 34 instead of just changing the value of "y" in line 27 to "5" . . . which we ended up doing anyway. It seems like the whole CInt step was unnecessary in the long run. Did I miss something?
Again, I'm loving these videos; just want to be sure I'm connecting all the dots!
Thanks, again.
@ejo74: Sorry it took me a few days to reply! You *could* just rely on Visual Basic to "do as it sees fit" when it comes to coercing your data types from strings to integers, or any similar type of coercion. In fact, years ago, you would often read about "visual basic's evil type coercion" ... clearly some people have strong opinions about this! Most developers come to the conclusion that it is a best practice to be deliberate, expressive and "take control" of data conversion / coercion. First, it forces YOU to understand what you're doing because your using CInt (etc.) intentionally. Second, it is a first line of defense against a variable that contains a value ("Bob") that cannot be converted to a number, for example. You catch that issue AT THE POINT OF CONVERSION, instead much deeper in your code where it would be difficult to ascertain exactly where the problem originated. It's a small nuance, to be sure, but a good practice nonetheless to get into -- that being: always be intentional in your coding and don't rely on short cuts. Some people go as far as to invoke something called "Option Strict" in their code -- to FORCE themselves to not rely on these sorts of things.
The following page has a great treatment of this issue:
Option Strict Statement
Hope that helps! Best wishes to you -- you are exactly the person Microsoft had in mind when asking me to create this series, so I'm hopeful you stick with it!
Hey Bob i am tiring to find some help on making a simple customers program so i can keep track of complaints and the resolutions done. I do have the database created in VB 2010 express your vidios are helpfull. But i need help on adding data to my database and saving it. can you sugest some code i can use or a place i can find it. I have tried different things and the code i am using is not saving it you can see it when it adds it to the grid but i cant get it to save.
@jpg60: I apologize for my completely underwhelming answer to your question ... outside of specific books and videos (like those on my own website) to help you learn how to work with data bases in your applications, I don't know of a free series of videos that you can check out, however I KNOW THEY EXIST ... I might start with MSDN's help to learn more about ADO.NET 4.x or specifically the Entity Framework. Perhaps one day Microsoft will ask me to create a series encompassing that content, however they've not asked yet.
Remove this comment
Remove this thread
close