Results 1 to 20 of 20

Thread: Print 1#, "Errrrrrrrr"

  1. #1

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472

    Print 1#, "Errrrrrrrr"

    Why doesn't this work

    Code:
    Print #1, Text1 & "Blah" & Text2
    It just prints "text1" in the document, and doesn't print the text in Text one...why?
    That arranged can be

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    Did you open it for Output?
    This works for me
    Code:
    Open "C:\windows\desktop\test.txt" For Output As #1
    Print #1, Text1 & "Blah" & Text2
    Close #1
    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?

    [Edited by QWERTY on 08-02-2000 at 01:55 PM]

  3. #3
    Guest
    If it printed "Text1", you probably had quotes around it.

  4. #4
    Member
    Join Date
    Jun 2000
    Posts
    37
    Is Text1 a textbox? If it is you have to use Text1.Text. Same goes for Text2 if that is also a textbox.

  5. #5
    Guest
    Text is the default property for a TextBox, hence you can omit it.

  6. #6
    Member
    Join Date
    Jun 2000
    Posts
    37
    Oh yeah, silly me!

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Use option explicit, and it will notice you about undefined variables
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    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"
    That arranged can be

  9. #9
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Command1_Click()
    
        Dim strOne As String, strTwo As String
        strOne = Text1.Text
        strTwo = Text2.Text
        
        MsgBox strOne, vbCritical, strTwo
        
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  10. #10

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    Not quite...im trying to save it into a text file...
    That arranged can be

  11. #11
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    what exactly do you want to save

    the msgbox line itself or the variables that are
    used in it.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  12. #12
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>...like this..

    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
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  13. #13

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    but that just prints what they typed in the textbox...I want it to print the whole command i mentioned above...
    That arranged can be

  14. #14

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    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 arranged can be

  15. #15
    Guest
    Code:
    Open "C:\myfile.txt" For Output As #1
    Print #1, Text1.text & vbCritical & Text2.text
    Close #1
    That should work..for whatever you are trying to do.

    Or are you trying to space it maybe?

    Code:
    Open "C:\myfile.txt" For Output As #1
    Print #1, Text1.text &  Chr$(13) & Chr$(10) & Text2.text
    Close #1
    What the...are you trying to do?

    [Edited by Matthew Gates on 08-02-2000 at 11:01 PM]

  16. #16

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    You guys are forgetting the MsgBox part...

    Code:
        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
    I want that to write

    MsgBox "Their message from Text1", vbCritical, "Their title from the Text2"

    into a text file...

    That arranged can be

  17. #17
    Guest
    Code:
    Open "C:\Windows\Desktop\myfile.txt" For Output As #1
    Print #1, "Msgbox " & Text1.Text & ", vbCritical, " & Text2.Text
    Close #1
    How's that? That should do the trick.

  18. #18

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    allright..i used that to get it...

    Code:
    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
    That finished it off...thanks all
    That arranged can be

  19. #19
    Guest
    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

  20. #20
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    what a mess

    Code:
    Print #1, "Msgbox """ & Text1.Text & """, vbCritical, """ & Text2.Text & """"
    two "" inside string quotes means a "
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width