@@ -36,7 +36,7 @@ Module modMain
3636 ' <Snippet1>
3737 Dim falseFlag As Boolean = False
3838 Dim trueFlag As Boolean = True
39-
39+
4040 Console.WriteLine( "{0} converts to {1}." , falseFlag, _
4141 Convert.ToInt64(falseFlag))
4242 Console.WriteLine( "{0} converts to {1}." , trueFlag, _
@@ -46,12 +46,12 @@ Module modMain
4646 ' True converts to 1.
4747 ' </Snippet1>
4848 End Sub
49-
49+
5050 Private Sub ConvertByte()
5151 ' <Snippet2>
5252 Dim bytes() As Byte = { Byte .MinValue, 14 , 122 , Byte .MaxValue}
5353 Dim result As Long
54-
54+
5555 For Each byteValue As Byte In bytes
5656 result = Convert.ToInt64(byteValue)
5757 Console.WriteLine( "Converted the {0} value {1} to the {2} value {3}." , _
@@ -65,35 +65,35 @@ Module modMain
6565 ' Converted the Byte value 255 to the Int64 value 255.
6666 ' </Snippet2>
6767 End Sub
68-
68+
6969 Private Sub ConvertChar()
7070 ' <Snippet3>
7171 Dim chars() As Char = { "a"c , "z"c , ChrW( 7 ), ChrW( 1023 ), _
7272 ChrW( Short .MaxValue), ChrW( &hFFFE ) }
7373 Dim result As Long
74-
74+
7575 For Each ch As Char in chars
7676 result = Convert.ToInt64(ch)
7777 Console.WriteLine( "Converted the {0} value '{1}' to the {2} value {3}." , _
7878 ch.GetType().Name, ch, _
7979 result.GetType().Name, result)
80- Next
80+ Next
8181 ' The example displays the following output:
8282 ' Converted the Char value 'a' to the Int64 value 97.
8383 ' Converted the Char value 'z' to the Int64 value 122.
84- ' Converted the Char value '' to the Int64 value 7.
85- ' Converted the Char value '? ' to the Int64 value 1023.
86- ' Converted the Char value '? ' to the Int64 value 32767.
87- ' Converted the Char value '? ' to the Int64 value 65534.
84+ ' Converted the Char value '' to the Int64 value 7.
85+ ' Converted the Char value 'Ͽ ' to the Int64 value 1023.
86+ ' Converted the Char value '翿 ' to the Int64 value 32767.
87+ ' Converted the Char value '' to the Int64 value 65534.
8888 ' </Snippet3>
8989 End Sub
90-
90+
9191 Private Sub ConvertDecimal()
9292 ' <Snippet4>
9393 Dim values() As Decimal = { Decimal .MinValue, - 1034.23d , - 12d , 0d , 147d , _
9494 199.55d , 9214.16d , Decimal .MaxValue }
9595 Dim result As Long
96-
96+
9797 For Each value As Decimal In values
9898 Try
9999 result = Convert.ToInt64(value)
@@ -103,8 +103,8 @@ Module modMain
103103 Catch e As OverflowException
104104 Console.WriteLine( "{0} is outside the range of the Int64 type." , _
105105 value)
106- End Try
107- Next
106+ End Try
107+ Next
108108 ' The example displays the following output:
109109 ' -79228162514264337593543950335 is outside the range of the Int64 type.
110110 ' Converted the Decimal value '-1034.23' to the Int64 value -1034.
@@ -116,13 +116,13 @@ Module modMain
116116 ' 79228162514264337593543950335 is outside the range of the Int64 type.
117117 ' </Snippet4>
118118 End Sub
119-
119+
120120 Private Sub ConvertDouble()
121121 ' <Snippet5>
122122 Dim values() As Double = { Double .MinValue, - 1.38e10 , - 1023 . 299 , - 12 . 98 , _
123123 0 , 9 . 113 e- 16 , 103 . 919 , 17834 . 191 , Double .MaxValue }
124124 Dim result As Long
125-
125+
126126 For Each value As Double In values
127127 Try
128128 result = Convert.ToInt64(value)
@@ -131,10 +131,10 @@ Module modMain
131131 result.GetType().Name, result)
132132 Catch e As OverflowException
133133 Console.WriteLine( "{0} is outside the range of the Int64 type." , value)
134- End Try
135- Next
134+ End Try
135+ Next
136136 ' -1.79769313486232E+308 is outside the range of the Int64 type.
137- ' -13800000000 is outside the range of the Int16 type .
137+ ' Converted the Double value '-13800000000' to the Int64 value -13800000000 .
138138 ' Converted the Double value '-1023.299' to the Int64 value -1023.
139139 ' Converted the Double value '-12.98' to the Int64 value -13.
140140 ' Converted the Double value '0' to the Int64 value 0.
@@ -144,12 +144,12 @@ Module modMain
144144 ' 1.79769313486232E+308 is outside the range of the Int64 type.
145145 ' </Snippet5>
146146 End Sub
147-
147+
148148 Private Sub ConvertInt16()
149149 ' <Snippet6>
150150 Dim numbers() As Short = { Int16.MinValue, - 1 , 0 , 121 , 340 , Int16.MaxValue }
151151 Dim result As Long
152-
152+
153153 For Each number As Short In numbers
154154 result = Convert.ToInt64(number)
155155 Console.WriteLine( "Converted the {0} value {1} to the {2} value {3}." , _
@@ -165,7 +165,7 @@ Module modMain
165165 ' Converted the Int16 value 32767 to the Int64 value 32767.
166166 ' </Snippet6>
167167 End Sub
168-
168+
169169 Private Sub ConvertInt32
170170 ' <Snippet7>
171171 Dim numbers() As Integer = { Int32.MinValue, - 1 , 0 , 121 , 340 , Int32.MaxValue }
@@ -183,16 +183,16 @@ Module modMain
183183 ' Converted the Int32 value 121 to the Int64 value 121.
184184 ' Converted the Int32 value 340 to the Int64 value 340.
185185 ' Converted the Int32 value 2147483647 to the Int64 value 2147483647.
186- ' </Snippet7>
187- End Sub
188-
186+ ' </Snippet7>
187+ End Sub
188+
189189 Private Sub ConvertObject()
190190 ' <Snippet8>
191191 Dim values() As Object = { True , - 12 , 163 , 935 , "x"c , #5/12/2009# , _
192192 "104" , "103.0" , "-1" , _
193193 "1.00e2" , "One" , 1.00e2 , 16 . 3 e42}
194194 Dim result As Long
195-
195+
196196 For Each value As Object In values
197197 Try
198198 result = Convert.ToInt64(value)
@@ -208,9 +208,9 @@ Module modMain
208208 Catch e As InvalidCastException
209209 Console.WriteLine( "No conversion to an Int64 exists for the {0} value {1}." , _
210210 value.GetType().Name, value)
211-
211+
212212 End Try
213- Next
213+ Next
214214 ' The example displays the following output:
215215 ' Converted the Boolean value True to the Int64 value 1.
216216 ' Converted the Int64 value -12 to the Int64 value -12.
@@ -227,12 +227,12 @@ Module modMain
227227 ' The Double value 1.63E+43 is outside the range of the Int64 type.
228228 ' </Snippet8>
229229 End Sub
230-
230+
231231 Private Sub ConvertSByte()
232232 ' <Snippet9>
233233 Dim numbers() As SByte = { SByte.MinValue, - 1 , 0 , 10 , SByte.MaxValue }
234234 Dim result As Long
235-
235+
236236 For Each number As SByte In numbers
237237 result = Convert.ToInt64(number)
238238 Console.WriteLine( "Converted the {0} value {1} to the {2} value {3}." , _
@@ -247,32 +247,32 @@ Module modMain
247247 ' Converted the SByte value 127 to the Int64 value 127.
248248 ' </Snippet9>
249249 End Sub
250-
250+
251251 Private Sub ConvertSingle()
252252 ' <Snippet10>
253253 Dim values() As Single = { Single .MinValue, - 1.38e10 , - 1023 . 299 , - 12 . 98 , _
254254 0 , 9 . 113 e- 16 , 103 . 919 , 17834 . 191 , Single .MaxValue }
255255 Dim result As Long
256-
256+
257257 For Each value As Single In values
258258 Try
259259 result = Convert.ToInt64(value)
260260 Console.WriteLine( "Converted the {0} value {1} to the {2} value {3}." , _
261261 value.GetType().Name, value, result.GetType().Name, result)
262262 Catch e As OverflowException
263263 Console.WriteLine( "{0} is outside the range of the Int64 type." , value)
264- End Try
265- Next
264+ End Try
265+ Next
266266 ' The example displays the following output:
267- ' -3.40282346638529E +38 is outside the range of the Int64 type.
268- ' -13799999488 is outside the range of the Int64 type .
269- ' Converted the Double value -1023.29901123047 to the Int64 value -1023.
270- ' Converted the Double value -12.9799995422363 to the Int64 value -13.
271- ' Converted the Double value 0 to the Int64 value 0.
272- ' Converted the Double value 9.11299983940444E -16 to the Int64 value 0.
273- ' Converted the Double value 103.918998718262 to the Int64 value 104.
274- ' Converted the Double value 17834.19140625 to the Int64 value 17834.
275- ' 3.40282346638529E +38 is outside the range of the Int64 type.
267+ ' -3.4028235E +38 is outside the range of the Int64 type.
268+ ' Converted the Single value -1.38E+10 to the Int64 value -13799999488 .
269+ ' Converted the Single value -1023.299 to the Int64 value -1023.
270+ ' Converted the Single value -12.98 to the Int64 value -13.
271+ ' Converted the Single value 0 to the Int64 value 0.
272+ ' Converted the Single value 9.113E -16 to the Int64 value 0.
273+ ' Converted the Single value 103.919 to the Int64 value 104.
274+ ' Converted the Single value 17834.191 to the Int64 value 17834.
275+ ' 3.4028235E +38 is outside the range of the Int64 type.
276276 ' </Snippet10>
277277 End Sub
278278
@@ -281,7 +281,7 @@ Module modMain
281281 Dim values() As String = { "One" , "1.34e28" , "-26.87" , "-18" , "-6.00" , _
282282 " 0" , "137" , "1601.9" , Int32.MaxValue.ToString() }
283283 Dim result As Long
284-
284+
285285 For Each value As String In values
286286 Try
287287 result = Convert.ToInt64(value)
@@ -292,8 +292,8 @@ Module modMain
292292 Catch e As FormatException
293293 Console.WriteLine( "The {0} value '{1}' is not in a recognizable format." , _
294294 value.GetType().Name, value)
295- End Try
296- Next
295+ End Try
296+ Next
297297 ' The example displays the following output:
298298 ' The String value 'One' is not in a recognizable format.
299299 ' The String value '1.34e28' is not in a recognizable format.
@@ -329,7 +329,7 @@ Module modMain
329329 ' Converted the UInt16 value 65535 to the Int64 value 65535.
330330 ' </Snippet12>
331331 End Sub
332-
332+
333333 Private Sub ConvertUInt32()
334334 ' <Snippet13>
335335 Dim numbers() As UInteger = { UInt32.MinValue, 121 , 340 , UInt32.MaxValue }
@@ -347,12 +347,12 @@ Module modMain
347347 ' Converted the UInt32 value 4,294,967,295 to the Int64 value 4,294,967,295.
348348 ' </Snippet13>
349349 End Sub
350-
350+
351351 Private Sub ConvertUInt64
352352 ' <Snippet14>
353353 Dim numbers() As ULong = { UInt64.MinValue, 121 , 340 , UInt64.MaxValue }
354354 Dim result As Long
355-
355+
356356 For Each number As ULong In numbers
357357 Try
358358 result = Convert.ToInt64(number)
@@ -369,7 +369,7 @@ Module modMain
369369 ' Converted the UInt64 value 121 to the Int64 value 121.
370370 ' Converted the UInt64 value 340 to the Int64 value 340.
371371 ' The UInt64 value 18446744073709551615 is outside the range of the Int64 type.
372- ' </Snippet14>
372+ ' </Snippet14>
373373 End Sub
374374End Module
375375
0 commit comments