Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Multiple newbie problems with files and printers
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tilex




PostPosted: Wed Feb 25, 2004 7:21 pm   Post subject: Multiple newbie problems with files and printers

Hi everyone, I'm new to this forum and to VB ( I was into learning C++ but I decided to take a little break and learn VB since it's good to know it and know multiple languages ) and I encountered multiple ( newbie ) problems.

#1
code:

    '
    ' PRINT
    '
    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
        Dim numCopies As Byte
        Dim printSettings As Drawing.Printing.PrinterSettings
        PrintDialog.ShowDialog()
        numCopies = PrintDialog.PrinterSettings.Copies()
        printSettings = PrintDialog.PrinterSettings()
        If printSettings.Copies > printSettings.MaximumCopies Then
            MsgBox("Your printer cannot print more than " + printSettings.MaximumCopies.ToString(), MsgBoxStyle.Exclamation, "Printer Error")
        End If
        End Sub


I can't use ShowDialog( ) in this code because I need to do something with PrintDialog.Document but I don't know what

#2
Quote:

'
' SAVE
'
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Dim fStream As System.IO.Stream
If SaveFileDialog.ShowDialog() = DialogResult.Yes Then
fStream = SaveFileDialog.OpenFile()
If Not fStream Is Nothing Then
FileOpen(FreeFile(), SaveFileDialog.FileName, OpenMode.Output, OpenAccess.Read, OpenShare.LockWrite)
FileClose(0)
fStream.Close()
End If
End If
End Sub


This code doesn't create the file... why ? I've never been good with files ( even in C, C++ and C# ... )

and #3 is almost the same as Save, but I don't know how to load... Sad

I'd appreciate any help, even if it's only a link to a good tutorial.
Thanks to every replyers
PS: Don't be too hard on me, it's my 3rd day of VB coding...
Sponsor
Sponsor
Sponsor
sponsor
tilex




PostPosted: Wed Feb 25, 2004 8:06 pm   Post subject: (No subject)

Sorry I didn't specify my compiler, Visual Studio 6 . NET ( Student version )
Tony




PostPosted: Wed Feb 25, 2004 11:54 pm   Post subject: (No subject)

hey, welcome to the site Very Happy I'd love to help, but I donno about printing Confused Last year in my project, I just send my output to an HTML file and then printed it using IE controls Laughing

preaty advanced stuff for the 3rd day of programming Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
tilex




PostPosted: Thu Feb 26, 2004 7:38 am   Post subject: (No subject)

It's because I've been on C/C++ for about half past a year ( 1 and 1/2 year ) and I've noticed things that are the same or similar

Ex:

This = Me
if = If .. Then + End If
while = While
for = For
public = Public
.... etc

and the structure is almost the same as C# ( except C# has more namespaces than VB )
wtd




PostPosted: Sat Feb 28, 2004 9:29 pm   Post subject: (No subject)

tilex wrote:
It's because I've been on C/C++ for about half past a year ( 1 and 1/2 year ) and I've noticed things that are the same or similar

Ex:

This = Me
if = If .. Then + End If
while = While
for = For
public = Public
.... etc

and the structure is almost the same as C# ( except C# has more namespaces than VB )


Yeah, there are only just so many ways to write the same thing. The only real variants from these patterns seem to be either conveniences:

code:
# This is Ruby

some_condition = true
print "something" if some_condition


Or for reasons of readability. The following in Eiffel certainly leaves no question as to what each part is doing, unlike a C-ish for loop.

code:
from i
   := 1
until
   i = 6
loop
   std_output.put_integer(i)
   std_output.put_new_line
end


And of course some languages feature additions to the usual complement of keywords, like "unless", which is nicer at times than saying "if not".

And any language that has access to the .NET runtime has the same number of namespaces, as those are a matter of libraries, rather than language. Smile

Programming languages, generally speaking, are very limited things that are useless on their own. It's the libraries of already written code that make them valuable or not. Java isn't the greatest language around. In fact, it isn't particularly good as a language at all. But it has a huge library of code already written that you can reuse, and that makes it an invaluable tool.

It's important to understand he difference if you're going to continue on with a career in computer science.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: