Last active
October 22, 2019 15:48
-
-
Save binki/f627fd3167069ba9554f8844c2f424d8 to your computer and use it in GitHub Desktop.
Example of quoting CSV in VB.Net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is some text, but it is free-form and might have double quotes (") in it | Text with a newline | 23 |
---|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System | |
Public Module Program | |
Public Sub Main() | |
Dim num = 23 | |
Dim value = "This is some text, but it is free-form and might have double quotes ("") in it" | |
Dim value2 = "Text with a" & Environment.NewLine & "newline" | |
Console.WriteLine(QuoteCsvField(value) & "," & QuoteCsvField(value2) &"," & num) | |
End Sub | |
Public Function QuoteCsvField(value As String) As String | |
Return """" & value.Replace("""", """""") & """" | |
End Function | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment