I'm developing a web page using
VB.NET that will write a string to a file (txt) based on user input, using the FileOpen/FileClose functions which works fine. User entry type (either textbox or ddl) has not been determined yet, so in the meantime, I've hard coded my strings:
Dim strFY = "salehistp:fyear"
Dim strPrd = "salehistp:period"
Dim strconc As String = strFY + " " + strPrd
The problem I have is that the text file that I write to using the FileOpen/FileClose functions contains the string with double quotation marks which I can't use in my text file:
"salehistp:fyear salehitsp:period"
I've tried the replace:
strconc.Replace("""", "")
Also the CleanInput function below passing strconc (CleanInput(strconc)):
Function CleanInput(ByVal strIn As String) As String
' Replace invalid characters with empty strings.
Return Regex.Replace(strIn, "[^\w\.@-]", "")
End Function
And I've tried using the following function passing strconc in the same manner:
Function CheckSQ(ByVal lsInput)
Dim llPos
Dim lsOutput
lsOutput = lsInput
llPos = 1
Do While llPos <> 0
llPos = InStr(llPos, lsOutput, "'", vbTextCompare)
If llPos <> 0 Then
lsOutput = Left(lsOutput, llPos - 1) & "`" & Right (lsOutput, Len(lsOutput) - llPos)
End If
Loop
llPos = 1
Do While llPos <> 0
llPos = InStr(llPos, lsOutput, """", vbTextCompare)
If llPos <> 0 Then
lsOutput = Left(lsOutput, llPos - 1) & "`" & Right(lsOutput, Len(lsOutput) - llPos)
End If
Loop
CheckSQ = lsOutput
End Function
None of these options have worked for me. My text file still contains data I wrote to it with double quotes. Any ideas on what I'm doing wrong or what can be done differently to remove the double quotation marks?
Your time is greatly appreciated.