Results 1 to 18 of 18

Thread: Menu question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    Does anyone have code that is used in the mnufilesaveas_click? I'm having trouble saving the data to the file I choose. Can anyone help?

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Post your code and We'll see what we can do!
    Mark
    -------------------

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253

    Exclamation Posted code

    Private Sub mnuFileSaveAs_Click()

    On Error Resume Next

    CommonDialog1.Filter = "All Text Files (*.txt)|*.txt"
    CommonDialog1.ShowSave

    Open CommonDialog1.FileName For Output As #1
    Print #1, Text1
    Close #1

    End Sub

    When I save the file and then go to the file to check and see if the data printed to the document, nothing is there.
    So if you can help I will appreciate it!

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Your code works OK for me!

    If you remove On Error Resume Next does an error occur?
    Mark
    -------------------

  5. #5
    New Member
    Join Date
    Aug 2000
    Posts
    15
    I pasted the code into a new project and it worked fine for me. Is text1 on the same form as the menu?
    That's not a BUG, It's a feature!



    VB6 Professional Service Pack 3
    Windows CE Embedded Visual Tools 3

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    No an error does not occur when I delete the On Error Resume Next. Does it matter if I'm using a picture box? What I'm asking is when I go to save is there a special way you save text from a picture box and then put it in a text file??

  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    How do you put text in a picture box?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253

    To Peak

    yes the menu is on the same form as the picture box that I'm trying to save.

  9. #9
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    A picture box???

    It's best to save text from a textbox and pictures from a picturebox!

    is your text1 a textbox?

    Mark
    -------------------

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    I wanted to preview the data that is why I put it in a picture box. Can you preview from a textbox? My Text1 is a picture box.

  11. #11
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Use a textbox!

    What is the data like that you want to preview?
    Mark
    -------------------

  12. #12
    New Member
    Join Date
    Aug 2000
    Posts
    15
    If your just dealing with text then you should be able to do what you want in a textbox. To save the text from a picturebox you would have to save it as an image using the savepicture statement:

    SavePicture text1.Image, CommonDialog1.filename

    If you do this, the result will be in .bmp format unless you specify another image format to save in. If you want the data saved as text, use a textbox.

    That's not a BUG, It's a feature!



    VB6 Professional Service Pack 3
    Windows CE Embedded Visual Tools 3

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    This is the kind of data I would like to preview:

    Private Sub PrintToObject()

    Dim ctlname As String
    Dim thisctl As Control
    Dim FIN As Double
    Dim BEG As Double
    Dim w As Double
    Dim w2 As Double
    Dim w3 As Double
    Dim c1 As Double
    Dim c2 As Double
    Dim c3 As Double
    Dim J As Integer

    'print headings
    PrtObj.Font = "Courier"
    PrtObj.FontSize = 14
    PrtObj.Print 'Blank Line
    PrtObj.Print Space(64) & frmCubeCupMain.txtDate
    PrtObj.Print 'Blank Line
    PrtObj.Print Space(30) & "Cube Cup" & Space(2) & "*" & Space(2) & frmCubeCupMain.txtCubeCupName & _
    Space(2) & "*"
    PrtObj.Print 'Blank Line
    PrtObj.Print 'Blank Line
    PrtObj.Print 'Blank Line
    PrtObj.Print Space(5) & "Grams" & Space(4) & "Cube Wt." & Space(6) & "Grams" & _
    Space(5) & "Cube Wt." & Space(7) & "Grams" & Space(6) & "Cube Wt."
    PrtObj.Print 'Blank Line

    'calculations
    FIN = 280
    BEG = FIN - 20.5

    For w = BEG To FIN Step 0.5
    w2 = w + 21
    w3 = w2 + 21
    c1 = w / (frmCubeCupMain.txtCVNumber * 0.06102338)
    c2 = w2 / (frmCubeCupMain.txtCVNumber * 0.06102338)
    c3 = w3 / (frmCubeCupMain.txtCVNumber * 0.06102338)

    PrtObj.Print Tab(6); Format(w, "##0.0"); Tab(16); Format(c1, "#0.0"); _
    Tab(29); Format(w2, "##0.0"); Tab(40); Format(c2, "#0.0"); _
    Tab(54); Format(w3, "##0.0"); Tab(66); Format(c3, "#0.0")

    J = J + 1
    If J = 6 Then
    PrtObj.Print
    J = 0
    End If

    Next w

    If ctlname = "PrtObj" Then
    MsgBox "Click okay to view more"
    thisctl.Cls
    End If

    End Sub

    But how do you preview this data in a textbox. What form do you use (prtobj.print)?

  14. #14
    New Member
    Join Date
    Aug 2000
    Posts
    15
    Change that picturebox to a text box and set the textbox properties:

    multiline=true
    locked=true
    scrollbars=vertical

    then use the following sub instead of the one you had.

    you shouldn't have to make anychanges to your menu coade to get the saveas to work now.


    Private Sub PrintToObject()

    Dim ctlname As String
    Dim thisctl As Control
    Dim FIN As Double
    Dim BEG As Double
    Dim w As Double
    Dim w2 As Double
    Dim w3 As Double
    Dim c1 As Double
    Dim c2 As Double
    Dim c3 As Double
    Dim J As Integer

    'print headings
    Text1.Font = "Courier"
    Text1.FontSize = 14
    Text1 = vbCrLf 'Blank Line
    Text1 = Text1 & Space(64) & frmCubeCupMain.txtDate
    Text1 = Text1 & vbCrLf 'Blank Line
    Text1 = Text1 & Space(30) & "Cube Cup" & Space(2) & "*" & Space(2) & frmCubeCupMain.txtCubeCupName & _
    Space(2) & "*" & vbCrLf
    Text1 = Text1 & vbCrLf 'Blank Line
    Text1 = Text1 & vbCrLf 'Blank Line
    Text1 = Text1 & vbCrLf 'Blank Line
    Text1 = Text1 & Space(5) & "Grams" & Space(4) & "Cube Wt." & Space(6) & "Grams" & _
    Space(5) & "Cube Wt." & Space(7) & "Grams" & Space(6) & "Cube Wt."
    Text1 = Text1 & vbCrLf 'Blank Line

    'calculations
    FIN = 280
    BEG = FIN - 20.5

    For w = BEG To FIN Step 0.5
    w2 = w + 21
    w3 = w2 + 21
    c1 = w / (frmCubeCupMain.txtCVNumber * 0.06102338)
    c2 = w2 / (frmCubeCupMain.txtCVNumber * 0.06102338)
    c3 = w3 / (frmCubeCupMain.txtCVNumber * 0.06102338)

    Text1 = Text1 & Space(5) & Format(w, "##0.0") & Space(12 - Len(Format(c1, "#0.0"))) & Format(c1, "#0.0") & _
    Space(11 - Len(Format(w2, "##0.0"))) & Format(w2, "##0.0") & Space(13 - Len(Format(c2, "#0.0"))) & Format(c2, "#0.0") & _
    Space(12 - Len(Format(w3, "##0.0"))) & Format(w3, "##0.0") & Space(14 - Len(Format(c3, "#0.0"))) & Format(c3, "#0.0") & vbCrLf

    J = J + 1
    If J = 6 Then
    Text1 = Text1 & vbCrLf
    J = 0
    End If

    Next w

    If ctlname = "PrtObj" Then
    MsgBox "Click okay to view more"
    thisctl.Cls
    End If

    End Sub
    That's not a BUG, It's a feature!



    VB6 Professional Service Pack 3
    Windows CE Embedded Visual Tools 3

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253

    Unhappy Headings are not printing

    My headings are not previewing in the textbox. All the other data is previewing though.
    Can you help?

  16. #16
    New Member
    Join Date
    Aug 2000
    Posts
    15
    I just tried it again, and I get the headings at the top of each column. stupid question, but is your scroll bar all the way at the top?
    That's not a BUG, It's a feature!



    VB6 Professional Service Pack 3
    Windows CE Embedded Visual Tools 3

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    yes my scrollbar is all the way up.

  18. #18
    New Member
    Join Date
    Aug 2000
    Posts
    15
    I am not sure then. If you want you can zip the project and send it to me and I'll see what happens then but when I run the code I posted I get the Headers displayed.

    [email protected]
    That's not a BUG, It's a feature!



    VB6 Professional Service Pack 3
    Windows CE Embedded Visual Tools 3

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