Skip to content

Commit 88fd430

Browse files
committed
fix snippets 5000 errors
1 parent f8753e2 commit 88fd430

File tree

5 files changed

+158
-159
lines changed

5 files changed

+158
-159
lines changed

snippets/visualbasic/System/String/ToLower/Project.vbproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
4+
<OutputType>Library</OutputType>
55
<TargetFramework>net9.0</TargetFramework>
66
</PropertyGroup>
77

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
1-
'<snippet1>
2-
Public Class ToLowerTest
3-
4-
Public Shared Sub Main()
1+
Public Class ToLowerTest
2+
3+
Public Shared Sub Run()
4+
'<snippet1>
55
Dim info As String() = {"Name", "Title", "Age", "Location", "Gender"}
6-
6+
77
Console.WriteLine("The initial values in the array are:")
88

99
Dim s As String
1010
For Each s In info
1111
Console.WriteLine(s)
12-
Next
12+
Next
1313

1414
Console.WriteLine("{0}The lowercase of these values is:", Environment.NewLine)
1515

1616
For Each s In info
1717
Console.WriteLine(s.ToLower())
18-
Next
18+
Next
1919

2020
Console.WriteLine("{0}The uppercase of these values is:", Environment.NewLine)
2121

22-
For Each s In info
22+
For Each s In info
2323
Console.WriteLine(s.ToUpper())
24-
Next
25-
End Sub
26-
End Class
27-
' The example displays the following output:
28-
' The initial values in the array are:
29-
' Name
30-
' Title
31-
' Age
32-
' Location
33-
' Gender
34-
'
35-
' The lowercase of these values is:
36-
' name
37-
' title
38-
' age
39-
' location
40-
' gender
41-
'
42-
' The uppercase of these values is:
43-
' NAME
44-
' TITLE
45-
' AGE
46-
' LOCATION
47-
' GENDER
48-
'</snippet1>
24+
Next
25+
26+
' The example displays the following output:
27+
' The initial values in the array are:
28+
' Name
29+
' Title
30+
' Age
31+
' Location
32+
' Gender
33+
'
34+
' The lowercase of these values is:
35+
' name
36+
' title
37+
' age
38+
' location
39+
' gender
40+
'
41+
' The uppercase of these values is:
42+
' NAME
43+
' TITLE
44+
' AGE
45+
' LOCATION
46+
' GENDER
47+
'</snippet1>
48+
End Sub
49+
End Class
Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,67 @@
1-
'<snippet1>
2-
' Sample for String.ToLower(CultureInfo)
3-
Imports System.Globalization
1+
Imports System.Globalization
42

53
Class Sample
6-
Public Shared Sub Main()
7-
Dim str1 As [String] = "INDIGO"
8-
' str2 = str1, except each 'I' is '\u0130' (Unicode LATIN CAPITAL I WITH DOT ABOVE).
9-
Dim str2 As New [String](New [Char]() {ChrW(&H0130), "N"c, "D"c, ChrW(&H0130), "G"c, "O"c})
10-
Dim str3, str4 As [String]
4+
'<snippet1>
5+
Public Shared Sub Run()
6+
Dim str1 As [String] = "INDIGO"
7+
' str2 = str1, except each 'I' is '\u0130' (Unicode LATIN CAPITAL I WITH DOT ABOVE).
8+
Dim str2 As New [String](New [Char]() {ChrW(&H130), "N"c, "D"c, ChrW(&H130), "G"c, "O"c})
9+
Dim str3, str4 As [String]
1110

12-
Console.WriteLine()
13-
Console.WriteLine("str1 = '{0}'", str1)
11+
Console.WriteLine()
12+
Console.WriteLine("str1 = '{0}'", str1)
1413

15-
Console.WriteLine()
16-
Console.WriteLine("str1 is {0} to str2.", _
14+
Console.WriteLine()
15+
Console.WriteLine("str1 is {0} to str2.",
1716
IIf(0 = [String].CompareOrdinal(str1, str2), "equal", "not equal"))
18-
CodePoints("str1", str1)
19-
CodePoints("str2", str2)
17+
CodePoints("str1", str1)
18+
CodePoints("str2", str2)
2019

21-
Console.WriteLine()
22-
' str3 is a lower case copy of str2, using English-United States culture.
23-
Console.WriteLine("str3 = Lower case copy of str2 using English-United States culture.")
24-
str3 = str2.ToLower(New CultureInfo("en-US", False))
20+
Console.WriteLine()
21+
' str3 is a lower case copy of str2, using English-United States culture.
22+
Console.WriteLine("str3 = Lower case copy of str2 using English-United States culture.")
23+
str3 = str2.ToLower(New CultureInfo("en-US", False))
2524

26-
' str4 is a lower case copy of str2, using Turkish-Turkey culture.
27-
Console.WriteLine("str4 = Lower case copy of str2 using Turkish-Turkey culture.")
28-
str4 = str2.ToLower(New CultureInfo("tr-TR", False))
25+
' str4 is a lower case copy of str2, using Turkish-Turkey culture.
26+
Console.WriteLine("str4 = Lower case copy of str2 using Turkish-Turkey culture.")
27+
str4 = str2.ToLower(New CultureInfo("tr-TR", False))
2928

30-
' Compare the code points in str3 and str4.
31-
Console.WriteLine()
32-
Console.WriteLine("str3 is {0} to str4.", _
29+
' Compare the code points in str3 and str4.
30+
Console.WriteLine()
31+
Console.WriteLine("str3 is {0} to str4.",
3332
IIf(0 = [String].CompareOrdinal(str3, str4), "equal", "not equal"))
34-
CodePoints("str3", str3)
35-
CodePoints("str4", str4)
36-
End Sub
33+
CodePoints("str3", str3)
34+
CodePoints("str4", str4)
35+
End Sub
3736

38-
Public Shared Sub CodePoints(title As [String], s As [String])
39-
Console.Write("{0}The code points in {1} are: {0}", Environment.NewLine, title)
40-
Dim c As Char
41-
For Each c In s
42-
Console.Write("{0:x4} ", AscW(c))
43-
Next c
44-
Console.WriteLine()
45-
End Sub
37+
Public Shared Sub CodePoints(title As [String], s As [String])
38+
Console.Write("{0}The code points in {1} are: {0}", Environment.NewLine, title)
39+
Dim c As Char
40+
For Each c In s
41+
Console.Write("{0:x4} ", AscW(c))
42+
Next c
43+
Console.WriteLine()
44+
End Sub
45+
46+
'str1 = 'INDIGO'
47+
'
48+
'str1 is not equal to str2.
49+
'
50+
'The code points in str1 are:
51+
'0049 004e 0044 0049 0047 004f
52+
'
53+
'The code points in str2 are:
54+
'0130 004e 0044 0130 0047 004f
55+
'
56+
'str3 = Lower case copy of str2 using English-United States culture.
57+
'str4 = Lower case copy of str2 using Turkish-Turkey culture.
58+
'
59+
'str3 is equal to str4.
60+
'
61+
'The code points in str3 are:
62+
'0069 006e 0064 0069 0067 006f
63+
'
64+
'The code points in str4 are:
65+
'0069 006e 0064 0069 0067 006f
66+
'</snippet1>
4667
End Class
47-
'
48-
'str1 = 'INDIGO'
49-
'
50-
'str1 is not equal to str2.
51-
'
52-
'The code points in str1 are:
53-
'0049 004e 0044 0049 0047 004f
54-
'
55-
'The code points in str2 are:
56-
'0130 004e 0044 0130 0047 004f
57-
'
58-
'str3 = Lower case copy of str2 using English-United States culture.
59-
'str4 = Lower case copy of str2 using Turkish-Turkey culture.
60-
'
61-
'str3 is equal to str4.
62-
'
63-
'The code points in str3 are:
64-
'0069 006e 0064 0069 0067 006f
65-
'
66-
'The code points in str4 are:
67-
'0069 006e 0064 0069 0067 006f
68-
'</snippet1>

snippets/visualbasic/System/TimeSpan/TryParse/TryParse1.vb

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
1-
' Example of the TimeSpan.Parse( String ) and TimeSpan.ToString( )
2-
' methods.
3-
4-
' <Snippet1>
1+
' <Snippet1>
52
Module TryParse
6-
Sub ParseTimeSpan( intervalStr As String )
3+
Sub ParseTimeSpan(intervalStr As String)
74
' Write the first part of the output line.
8-
Console.Write( "{0,20} ", intervalStr )
5+
Console.Write("{0,20} ", intervalStr)
96

107
' Parse the parameter, and then convert it back to a string.
11-
Dim intervalVal As TimeSpan
12-
If TimeSpan.TryParse( intervalStr, intervalVal ) Then
13-
Dim intervalToStr As String = intervalVal.ToString( )
14-
8+
Dim intervalVal As TimeSpan
9+
If TimeSpan.TryParse(intervalStr, intervalVal) Then
10+
Dim intervalToStr As String = intervalVal.ToString()
11+
1512
' Pad the end of the TimeSpan string with spaces if it
1613
' does not contain milliseconds.
17-
Dim pIndex As Integer = intervalToStr.IndexOf( ":"c )
18-
pIndex = intervalToStr.IndexOf( "."c, pIndex )
19-
If pIndex < 0 Then intervalToStr &= " "
20-
21-
Console.WriteLine( "{0,21}", intervalToStr )
22-
' Handle failure of TryParse method.
23-
Else
14+
Dim pIndex As Integer = intervalToStr.IndexOf(":"c)
15+
pIndex = intervalToStr.IndexOf("."c, pIndex)
16+
If pIndex < 0 Then intervalToStr &= " "
17+
18+
Console.WriteLine("{0,21}", intervalToStr)
19+
' Handle failure of TryParse method.
20+
Else
2421
Console.WriteLine("Parse operation failed.")
2522
End If
26-
End Sub
23+
End Sub
2724

28-
Public Sub Main( )
29-
Console.WriteLine( "{0,20} {1,21}", _
30-
"String to Parse", "TimeSpan" )
31-
Console.WriteLine( "{0,20} {1,21}", _
32-
"---------------", "---------------------" )
25+
Public Sub Run()
26+
Console.WriteLine("{0,20} {1,21}",
27+
"String to Parse", "TimeSpan")
28+
Console.WriteLine("{0,20} {1,21}",
29+
"---------------", "---------------------")
3330

3431
ParseTimeSpan("0")
3532
ParseTimeSpan("14")
@@ -40,12 +37,12 @@ Module TryParse
4037
ParseTimeSpan("0023:0059:0059.0099")
4138
ParseTimeSpan("23:0:0")
4239
ParseTimeSpan("24:0:0")
43-
ParseTimespan("0:59:0")
40+
ParseTimeSpan("0:59:0")
4441
ParseTimeSpan("0:60:0")
45-
ParseTimespan("0:0:59")
42+
ParseTimeSpan("0:0:59")
4643
ParseTimeSpan("0:0:60")
4744
ParseTimeSpan("10:")
48-
ParsetimeSpan("10:0")
45+
ParseTimeSpan("10:0")
4946
ParseTimeSpan(":10")
5047
ParseTimeSpan("0:10")
5148
ParseTimeSpan("10:20:")
@@ -55,8 +52,9 @@ Module TryParse
5552
ParseTimeSpan("10.")
5653
ParseTimeSpan("10.12")
5754
ParseTimeSpan("10.12:00")
58-
End Sub
59-
End Module
55+
End Sub
56+
End Module
57+
6058
' This example generates the following output:
6159
' String to Parse TimeSpan
6260
' --------------- ---------------------

snippets/visualbasic/System/TimeSpan/TryParse/tryparse2.vb

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
11
' Visual Basic .NET Document
22
Option Strict On
33

4-
' <Snippet2>
54
Imports System.Globalization
65

76
Module Example
8-
Public Sub Main()
9-
Dim values() As String = { "6", "6:12", "6:12:14", "6:12:14:45",
10-
"6.12:14:45", "6:12:14:45.3448",
11-
"6:12:14:45,3448", "6:34:14:45" }
12-
Dim cultures() As CultureInfo = { New CultureInfo("en-US"),
7+
Public Sub Main()
8+
' <Snippet2>
9+
Dim values() As String = {"6", "6:12", "6:12:14", "6:12:14:45",
10+
"6.12:14:45", "6:12:14:45.3448",
11+
"6:12:14:45,3448", "6:34:14:45"}
12+
Dim cultures() As CultureInfo = {New CultureInfo("en-US"),
1313
New CultureInfo("ru-RU"),
14-
CultureInfo.InvariantCulture }
15-
16-
Dim header As String = String.Format("{0,-17}", "String")
17-
For Each culture As CultureInfo In cultures
18-
header += If(culture.Equals(CultureInfo.InvariantCulture),
14+
CultureInfo.InvariantCulture}
15+
16+
Dim header As String = String.Format("{0,-17}", "String")
17+
For Each culture As CultureInfo In cultures
18+
header += If(culture.Equals(CultureInfo.InvariantCulture),
1919
String.Format("{0,20}", "Invariant"),
2020
String.Format("{0,20}", culture.Name))
21-
Next
22-
Console.WriteLine(header)
23-
Console.WriteLine()
24-
25-
For Each value As String In values
26-
Console.Write("{0,-17}", value)
27-
For Each culture As CultureInfo In cultures
28-
Dim interval As New TimeSpan()
29-
If TimeSpan.TryParse(value, culture, interval) Then
30-
Console.Write("{0,20}", interval.ToString("c"))
31-
Else
32-
Console.Write("{0,20}", "Unable to Parse")
33-
End If
34-
Next
35-
Console.WriteLine()
36-
Next
37-
End Sub
21+
Next
22+
Console.WriteLine(header)
23+
Console.WriteLine()
24+
25+
For Each value As String In values
26+
Console.Write("{0,-17}", value)
27+
For Each culture As CultureInfo In cultures
28+
Dim interval As New TimeSpan()
29+
If TimeSpan.TryParse(value, culture, interval) Then
30+
Console.Write("{0,20}", interval.ToString("c"))
31+
Else
32+
Console.Write("{0,20}", "Unable to Parse")
33+
End If
34+
Next
35+
Console.WriteLine()
36+
Next
37+
38+
' The example displays the following output:
39+
' String en-US ru-RU Invariant
40+
'
41+
' 6 6.00:00:00 6.00:00:00 6.00:00:00
42+
' 6:12 06:12:00 06:12:00 06:12:00
43+
' 6:12:14 06:12:14 06:12:14 06:12:14
44+
' 6:12:14:45 6.12:14:45 6.12:14:45 6.12:14:45
45+
' 6.12:14:45 6.12:14:45 6.12:14:45 6.12:14:45
46+
' 6:12:14:45.3448 6.12:14:45.3448000 Unable to Parse 6.12:14:45.3448000
47+
' 6:12:14:45,3448 Unable to Parse 6.12:14:45.3448000 Unable to Parse
48+
' 6:34:14:45 Unable to Parse Unable to Parse Unable to Parse
49+
' </Snippet2>
50+
End Sub
3851
End Module
39-
' The example displays the following output:
40-
' String en-US ru-RU Invariant
41-
'
42-
' 6 6.00:00:00 6.00:00:00 6.00:00:00
43-
' 6:12 06:12:00 06:12:00 06:12:00
44-
' 6:12:14 06:12:14 06:12:14 06:12:14
45-
' 6:12:14:45 6.12:14:45 6.12:14:45 6.12:14:45
46-
' 6.12:14:45 6.12:14:45 6.12:14:45 6.12:14:45
47-
' 6:12:14:45.3448 6.12:14:45.3448000 Unable to Parse 6.12:14:45.3448000
48-
' 6:12:14:45,3448 Unable to Parse 6.12:14:45.3448000 Unable to Parse
49-
' 6:34:14:45 Unable to Parse Unable to Parse Unable to Parse
50-
' </Snippet2>

0 commit comments

Comments
 (0)