Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quotation Marks In Test File 1

Status
Not open for further replies.

clapper62

Programmer
Apr 17, 2003
113
0
0
US
I'm writing a program that gathers computer information using WMI
I have a function that returns the installed OS

Public Function GetOS() As String
On Error Resume Next
Dim strComputer As String
Dim objWMIService As Object
Dim objOperatingSystem As Object
Dim colOperatingSystems

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
GetOS = GetOS & "001" & objOperatingSystem.Caption & objOperatingSystem.Version & vbCrLf
Next

End Function

And Code to write this to a text file

Dim strFilePath As String
strFilePath = GetDBPath
Open strFilePath & "OutputFile.txt" For Output As #1
Write #1, GetOS
Close #1

the generated text file contains quotation marks that I don't want like this
"001Microsoft Windows 7 Home Premium 6.1.7601
"
instead of what I would like
001Microsoft Windows 7 Home Premium 6.1.7601

does anyone know where the unwanted quotation marks come from and how to get rid of them?



"There is no pleasure in having nothing to do; the fun is having lots to do and not doing it.
." - Andrew Jackson
 
Instead of Write #n use Print #n if you don't want quotes around strings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top