|
-
Oct 20th, 2000, 09:49 AM
#1
Thread Starter
Lively Member
I am Trying to write to a text file but It keeps adding quotes to my statement. It is a command and won't run with qoutes around it.
It looks like this "nbtstat -a >""c:\output.txt"""
It is supposed to look like this nbtstat -a >"c:\output.txt"
Here is my code.
Private Sub Command1_Click()
'Form Contains Text2, Text1, RichTextBox1, and Command1
Dim MyCommand As String
Dim ComputerName As String
Dim Test As String
'The Computer You Want Info About.
ComputerName = Text1.Text
'Strings the NBTSTAT command with the Computer Name and an Output File.
MyCommand = "nbtstat -a " & computer & " >" & Chr(34) & "c:\output.txt" & Chr(34)
'Moves the Command to the Test Varible
'Then to The Text2 text box to Check Formatting
Test = MyCommand
Text2.Text = Test
'Writes the Command to a Batch File
Open "C:\Command.bat" For Output As #1
Write #1, Text2.Text
Close #1
'Runs the Batch File
Shell "C:\Command.bat", vbHide
'Recieves an Error Because The Batch File Contains Too Many Quotes
'And the Output File hasn't Been Created
RichTextBox1.FileName = "C:\Output.txt"
End Sub
Thanks for any help
Brandon
-
Oct 20th, 2000, 09:55 AM
#2
Frenzied Member
try this
instead of:
MyCommand = "nbtstat -a " & computer & " >" & Chr(34) & "c:\output.txt" & Chr(34)
do:
MyCommand = "nbtstat -a " & computer & " >" & """c:\output.txt"""
-
Oct 20th, 2000, 01:03 PM
#3
Thread Starter
Lively Member
I got the exact same Result.
Thanks
Brandon
-
Oct 20th, 2000, 01:08 PM
#4
Addicted Member
You have to use Print # statement for writing data to files without quotes. If you use Write # statement, you'll allways get quotes.
Example:
Code:
Dim fNum As Integer
fNum=FreeFile
Open file.dat For Output As fNum
Print #fNum, "string for output without quotes"
Close #fNum
I think this would work fine.
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Oct 20th, 2000, 01:09 PM
#5
Fanatic Member
Where you have:
Code:
Write #1, Text2.Text
replace it with:
Code:
Print #1, Text2.Text
The "Write" statement puts the quotes around your string. The "Print" statement puts exactly what you tell it to.
---------
oopps, somebody beat me to it.
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Oct 20th, 2000, 01:09 PM
#6
Addicted Member
I forgot: FILE.DAT must be quoted ("file.dat")!
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|