|
-
Aug 23rd, 2000, 08:50 AM
#1
Thread Starter
Addicted Member
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?
-
Aug 23rd, 2000, 09:04 AM
#2
Frenzied Member
Post your code and We'll see what we can do!
-
Aug 23rd, 2000, 09:09 AM
#3
Thread Starter
Addicted Member
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!
-
Aug 23rd, 2000, 09:57 AM
#4
Frenzied Member
Your code works OK for me!
If you remove On Error Resume Next does an error occur?
-
Aug 23rd, 2000, 10:01 AM
#5
New Member
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
-
Aug 23rd, 2000, 10:05 AM
#6
Thread Starter
Addicted Member
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??
-
Aug 23rd, 2000, 10:08 AM
#7
Fanatic Member
How do you put text in a picture box?
-
Aug 23rd, 2000, 10:08 AM
#8
Thread Starter
Addicted Member
To Peak
yes the menu is on the same form as the picture box that I'm trying to save.
-
Aug 23rd, 2000, 10:08 AM
#9
Frenzied Member
A picture box???
It's best to save text from a textbox and pictures from a picturebox!
is your text1 a textbox?
-
Aug 23rd, 2000, 10:24 AM
#10
Thread Starter
Addicted Member
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.
-
Aug 23rd, 2000, 10:29 AM
#11
Frenzied Member
Use a textbox!
What is the data like that you want to preview?
-
Aug 23rd, 2000, 10:33 AM
#12
New Member
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
-
Aug 23rd, 2000, 10:41 AM
#13
Thread Starter
Addicted Member
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)?
-
Aug 23rd, 2000, 12:05 PM
#14
New Member
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
-
Aug 23rd, 2000, 12:33 PM
#15
Thread Starter
Addicted Member
Headings are not printing
My headings are not previewing in the textbox. All the other data is previewing though.
Can you help?
-
Aug 23rd, 2000, 12:40 PM
#16
New Member
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
-
Aug 23rd, 2000, 12:51 PM
#17
Thread Starter
Addicted Member
yes my scrollbar is all the way up.
-
Aug 23rd, 2000, 01:00 PM
#18
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|