| |

VerySource

 Forgot password?
 Register
Search
View: 1065|Reply: 8

[Vb.net? c #? Is it because I'm looking away? ] My brother is not talented, please master to explain to me why this cod

[Copy link]

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-17 10:00:01
| Show all posts |Read mode
Dim dlg As New OpenFileDialog
        dlg.Multiselect = False
        dlg.CheckFileExists = True
        If dlg.ShowDialog () = Windows.Forms.DialogResult.OK Then
            Dim fs As IO.FileStream = dlg.OpenFile ()
            Dim bzData As Byte ()
            ReDim bzData (fs.Length)
            fs.Read (bzData, 0, fs.Length-1)
            Dim strFileData As String = System.Text.Encoding.ASCII.GetString (bzData)
            Dim res As System.Text.RegularExpressions.MatchCollection
            res = System.Text.RegularExpressions.Regex.Matches (strFileData, "\r\n")
            Dim strRes As String = String.Format ("There are {0: d} lines in total.", Res.Count + 1)
            MessageBox.Show (strRes)
        End If

This is written in vb.net. It seemed nothing at first glance, and the person with eyesight probably saw it. In vb.net, the escape character\r\n of c # is used. So, vb.net does not need to use vbcrlf to indicate a carriage return and line feed in the future? Using "\r\n" directly? Gosh, this is Microsoft's original design? Still an oversight?
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-13 11:00:01
| Show all posts
Not surprisingly, VB.Net can either use vbcrlf to indicate a carriage return or line feed, or use C # escape characters.
Because VB.Net and C # are originally working under the same .Net framework
Reply

Use magic Report

1

Threads

12

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-15 16:30:01
| Show all posts
Cannot compile
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-6 18:15:01
| Show all posts
This is a regular expression, what's up with VB, c #
Reply

Use magic Report

0

Threads

8

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-7 13:30:01
| Show all posts
Some things are universal.
For code in data binding
C #: <% # DataBinder.Eval (Container.DataItem, "Column Name")%> can also be used in VB.NET.
Reply

Use magic Report

0

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-4-19 06:15:02
| Show all posts
Topwnc_123

It is very clear to write System.Text.RegularExpressions
Regular expression
Reply

Use magic Report

0

Threads

38

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-4-23 08:45:01
| Show all posts
This "\r\n" is the escape of regular expression
Reply

Use magic Report

0

Threads

4

Posts

68.00

Credits

Credits
68.00

 China

Post time: 2020-4-25 19:07:45
| Show all posts
Learned, the escape character vb.net can also recognize
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-26 15:30:01
| Show all posts
Oh. Ha ha. understood. So that's the case. I know. Because\r\n itself means 4 characters, not the escape character in c #, the escape character\r\n in c # means 2 bytes of 0d0a. Hahahaha. Thank you very much, thank you ~ Ha ha.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list