From the course: Visual Basic Essential Training
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Implicit covert strings to numbers - Visual Basic Tutorial
From the course: Visual Basic Essential Training
Implicit covert strings to numbers
- [Instructor] The TryParse method is one of the safest ways to turn string values into numeric values. It is part of the .NET classes and you should know how to use it. Having said that, it's also good to know that the default conversions available from Visual Basic will suffice in many situations. Let's look at implicit conversions. First, a note. I've changed the startup URI to ParseWindow. I'll be writing the code in this vb file, and what I want to do is take some user input from this control, which is called InputTextBox, and I want to attempt to convert that into an integer and a double. I'll start by taking myInteger and getting the text out of the TextBox. So this is an implicit conversion because this is a string and this is an integer. So copy this, and then I'll change this to my double. That's the basics of it. Then I'm going to show the integer value and then the double value. All right, let's run it. When I click on this button, it parses it like we expect. If I add…
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Understanding strings6m 41s
-
(Locked)
Create string variables4m
-
(Locked)
Concatenation and interpolation2m 56s
-
(Locked)
Search string contents2m 59s
-
(Locked)
Modify string contents3m 3s
-
(Locked)
String creation with StringBuilder5m 39s
-
(Locked)
Compare and equals5m 51s
-
(Locked)
Convert and format numbers to strings8m 4s
-
(Locked)
Implicit covert strings to numbers2m 50s
-
(Locked)
Use Parse and TryParse conversions5m 4s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-