What does the two textboxes contain?

Answers
a. they contain the numbers 123 and 456 respectively.
b. they contain strings that can be interpreted as the numbers 123 and 456.
If you answered a then you are in precise in your thinking.
To you, you see numbers, your not thinking about how the computer interpretation of them.
If you answered b then you are correct because the type of the textbox.text is a string.
Remember this fact will help you minimize casting errors like Unable to cast String to Double
It is a string not a number and such can contain non-numerical characters. so check they are valid numbers before treating them as such.

Answers
a. they contain the numbers 123 and 456 respectively.
b. they contain strings that can be interpreted as the numbers 123 and 456.
If you answered a then you are in precise in your thinking.
To you, you see numbers, your not thinking about how the computer interpretation of them.
If you answered b then you are correct because the type of the textbox.text is a string.
Remember this fact will help you minimize casting errors like Unable to cast String to Double
It is a string not a number and such can contain non-numerical characters. so check they are valid numbers before treating them as such.
Dim ValueOfA As Double If Double.TryParse(Me.Txt_NumberA.Text, ValueOfA) = False Then MessageBox.Show("Number A is not a valid number") Exit Sub End If Dim ValueOfB As Double If Double.TryParse(Me.Txt_NumberA.Text, ValueOfB) = False Then MessageBox.Show("Number B is not a valid number") Exit Sub End If Dim result As Double = ValueOfA * ValueOfB MessageBox.Show(String.Format("Result of {0} * {1} = {2}", ValueOfA, ValueOfB, result))
1 Comments On This Entry
Page 1 of 1

Michael26
20 March 2013 - 03:49 AM
I don't understand why people can't use the numericUpDown control and avoid casting altogether, it's totally unnecessary
Page 1 of 1
Search My Blog
Recent Entries
Recent Comments
0 user(s) viewing
0 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)
← April 2018 →
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- .net
- .net4
- bf
- brainfuck
- Codeplex
- Coding
- custom Control
- custom controls
- DIC CodeAID VS Gallery
- Dice
- Die
- DLL
- Englishify
- Extension
- Extension Method
- ExtMethods
- F#
- Functional
- Functional Programming
- Graph
- Graphs
- Language Intergrated Query.
- Library
- LINQ
- LINQ Codes
- LISP interpreter
- Macro
- My Games
- Nemerle.
- net
- podcast
- Project
- Project Cider
- RadixSort Generics (Of T)
- restricted textbox
- Rolling
- rss
- rss feed
- Scribblings
- shadowtext
- Tips
- Transparent Textbox
- vb
- vb.net
- VB.net +LINQ Extension Method
- vb.net 1-Liners
- vb.net visual basic vs2010 .net4
- vs2010
- Weird
- XM
- xml
- XML Literals