Why doesn't this work
It just prints "text1" in the document, and doesn't print the text in Text one...why?Code:Print #1, Text1 & "Blah" & Text2
Printable View
Why doesn't this work
It just prints "text1" in the document, and doesn't print the text in Text one...why?Code:Print #1, Text1 & "Blah" & Text2
Did you open it for Output?
This works for me
What do you have in Text1? As default it is always "Text1" for TextBox1, "Text2" for TextBox2 and so on. Are you suru that you are changing the contest of the textbox?Code:Open "C:\windows\desktop\test.txt" For Output As #1
Print #1, Text1 & "Blah" & Text2
Close #1
[Edited by QWERTY on 08-02-2000 at 01:55 PM]
If it printed "Text1", you probably had quotes around it.
Is Text1 a textbox? If it is you have to use Text1.Text. Same goes for Text2 if that is also a textbox.
Text is the default property for a TextBox, hence you can omit it.
Oh yeah, silly me!
Use option explicit, and it will notice you about undefined variables
Well...Im having trouble making the correct format for it... so here is what I am trying to do...
I want the program to print this vb command into the text file..
Code:MsgBox "Their message from Text1", vbCritical, "Their title from the Text2"
Code:Private Sub Command1_Click()
Dim strOne As String, strTwo As String
strOne = Text1.Text
strTwo = Text2.Text
MsgBox strOne, vbCritical, strTwo
End Sub
Not quite...im trying to save it into a text file...
what exactly do you want to save
the msgbox line itself or the variables that are
used in it.
Code:Private Sub Command1_Click()
Dim strOne As String, strTwo As String
strOne = Text1.Text
strTwo = Text2.Text
Open "c:\my documents\try.txt" For Output As #1
Print #1, strOne
Print #1, strTwo
Close #1
Open "c:\my documents\try.txt" For Input As #1
Input #1, strOne, strTwo
Close #1
MsgBox strOne, vbCritical, strTwo
End Sub
but that just prints what they typed in the textbox...I want it to print the whole command i mentioned above...
I want to save this exact line into a txt file
MsgBox "Their message from Text1", vbCritical, "Their title from the Text2"
but...the messages would be Text1 and Text2 instead of what I put for the text...
That should work..for whatever you are trying to do.Code:Open "C:\myfile.txt" For Output As #1
Print #1, Text1.text & vbCritical & Text2.text
Close #1
Or are you trying to space it maybe?
What the...are you trying to do?Code:Open "C:\myfile.txt" For Output As #1
Print #1, Text1.text & Chr$(13) & Chr$(10) & Text2.text
Close #1
[Edited by Matthew Gates on 08-02-2000 at 11:01 PM]
You guys are forgetting the MsgBox part...
I want that to writeCode:dlgMain.Flags = &H1000
dlgMain.DialogTitle = "Open"
dlgMain.Filter = "txt Files (*.txt)|*.txt|"
dlgMain.CancelError = False
dlgMain.ShowSave
If Len(dlgMain.FileName) > 0 Then
strFileName = dlgMain.FileName
Me.Caption = "Program - [" & dlgMain.FileTitle & "]"
Open dlgMain.FileTitle For Output As #1
If Option1.Value = True Then
'HERE
Print #1, "MsgBox " & """ & text1 & """ & ", vbCritical, " & """ & Text2 & """
Close #1
Else
End If
MsgBox "Their message from Text1", vbCritical, "Their title from the Text2"
into a text file...
How's that? That should do the trick.Code:Open "C:\Windows\Desktop\myfile.txt" For Output As #1
Print #1, "Msgbox " & Text1.Text & ", vbCritical, " & Text2.Text
Close #1
allright..i used that to get it...
That finished it off...thanks allCode:Private Sub Command1_Click()
Open "C:\Windows\Desktop\myfile.txt" For Output As #1
Print #1, "Msgbox " & """" & Text1.Text & """" & ", vbCritical, " & """" & Text2.Text & """"
Close #1
End Sub
Anyway, instead of using """", you should use Chr$(34) instead. That'll put the quotes around what you say. So instead of all that, you have:
Code:Open "C:\Windows\Desktop\myfile.txt" For Output As #1
Print #1, "Msgbox " & Chr$(34) & Text1.Text & Chr$(34) & ", vbCritical, " & Chr$(34) & Text2.Text & Chr$(34)
Close #1
two "" inside string quotes means a "Code:Print #1, "Msgbox """ & Text1.Text & """, vbCritical, """ & Text2.Text & """"