المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : طلب كود لأمري الفتح و الطباعة بالـvb.net


الظل الأسود
04-Jan-2008, 02:59 PM
ساعدوني لأني حاولت ولم أفلح
لقد انهيت جزء كبير من البرنامج وباقي أشياء بسيطه وأنا عندي متحانات صعبة جداً
كل التفاصيل كالتالي :
فكرةالبرنامج حقي أني أقوم بالكتابة على ملف
من نوع notepad كالتالي :


Dim days(5) AsString
days(1) = "Sat"
days(2) = "Sun"
days(3) = "Mon"
days(4) = "Tus"
days(5) = "Wed"
FileOpen(1, "Schaduale.Doc", OpenMode.Output ) '
For i = 1 To 4
PrintLine(1, "Room #" & room(i))
PrintLine(1, " ")
PrintLine(1, "-------------------------------------------------------------------------------------------------------------")
Print(1, "Day", TAB)
For t = 0 To 6
Print(1, " " & VB6.GetItemStri ng(TimeList, t), TAB)
Next
PrintLine(1, " ")
PrintLine(1, "-------------------------------------------------------------------------------------------------------------")
For d = 1 To 5
Print(1, days(d), TAB)
For j = 1 To 7
If AssignList(i, j) <> -1 Then
Print(1, course(AssignLi st(i, j)), TAB)
Else
Print(1, " **** ", TAB)
EndIf
Next
PrintLine(1, " ")
PrintLine(1, "-------------------------------------------------------------------------------------------------------------")
Next
PrintLine(1, " ")
PrintLine(1, " ")
Next
FileClose(1)
Shell("notepad Schaduale.Doc", AppWinStyle.Nor malFocus)
EndSub
و اريد عمل خيار للحفظ و خيار للطباعة ولا أعرف طريقة كتابة الكود حق اللإثنين
علماً بأن البيانات المدخلة مكتوبة على notepad
و وجدت هذه الأكواد من أمثلة ولكن لم تضبط معي وهي كالتالي :

كود الطباعة كالتالي :
PrivateSub mnuitmPrint_Cli ck(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles mnuitmPrint.Cli ck
' Make a PrintDocument and attach it to
' the Print dialog.
dlgPrint.Docume nt = PreparePrintDoc ument()

' Display the print dialog and print.
If dlgPrint.ShowDi alog = Windows.Forms.D ialogResult.OK Then
PrintDocument1. Print()
EndIf

EndSub





PrivateSub PrintDocument1_ PrintPage(ByVal sender As System.Object, ByVal e As _
System.Drawing. Printing.PrintP ageEventArgs) Handles PrintDocument1. PrintPage
'to catch drawings being displayed on the form
Dim g As Graphics
g = e.Graphics
g.DrawImage(new Bitmap, 0, 0)
g.Dispose()

' to print in one page
e.HasMorePages = False
EndSub

PrivateFunction PreparePrintDoc ument() As Printing.PrintD ocument
' Make the PrintDocument object.
Dim print_document AsNew Printing.PrintD ocument

' Install the PrintPage event handler.
AddHandler print_document. PrintPage, AddressOf PrintDocument1_ PrintPage

' Return the object.
Return print_document
EndFunction

'************** *************** *************** *************
' Print Preview the picture
'************** *************** *************** *************
PrivateSub mnuitmPrintPrev iew_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles mnuitmPrintPrev iew.Click

'Make a PrintDocument and attach it to
' the PrintPreview dialog.
dlgPrintPreview .Document = dlgPrint.Docume nt

' Display a print preview.
dlgPrintPreview .WindowState = FormWindowState .Maximized

dlgPrintPreview .ShowDialog()
EndSub
كود الحفظ كالتالي :

PrivateSub mnuitmSave_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles mnuitmSave.Clic k
'Did the user click the ok button before this time ?
If resultDialog = Windows.Forms.D ialogResult.OK Then

'Save the file with Bmp format
Try
newBitmap.Save( dlgSaveFile.Fil eName, Imaging.ImageFo rmat.Bmp)
Catch ex As FileNotFoundExc eption
MessageBox.Show ("File Dont Exists Name", "Error", MessageBoxButto ns.OK, MessageBoxIcon. Error)
EndTry

Else
'display save dialog to specify the ******** and save.
saveAS()
EndIf
EndSub

'************** *************** *************** *************
' Save As the picture
'************** *************** *************** *************
PrivateSub mnuitmSaveAs_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles mnuitmSaveAs.Cl ick
'display save dialog to specify the ******** and save.
saveAS()
EndSub

'this method to display save dialog to specify the ******** and save.
PrivateSub saveAS()
' to specify certain files' types
dlgSaveFile.Fil ter = "Bitmap Image|*.bmp"

' to specify title of the save dialog
dlgSaveFile.Tit le = "Save as an Bitmap Image File"

' this variable to save the result of the save dialog
resultDialog = dlgSaveFile.Sho wDialog()

'Did the user click the ok button?
If resultDialog = Windows.Forms.D ialogResult.OK Then

' If the file name is not an empty string open it for saving.
If dlgSaveFile.Fil eName = ""OrElse dlgSaveFile.Fil eName = NothingThen
MessageBox.Show ("Invaild File Name", "Error", MessageBoxButto ns.OK, MessageBoxIcon. Error)

Else
'Save the file with Bmp format
newBitmap.Save( dlgSaveFile.Fil eName, Imaging.ImageFo rmat.Bmp)
EndIf
EndIf
EndSub

al_fanar
05-Jan-2008, 01:13 AM
هذا موقع يحتوي على مجموعه مختاره من الأكواد في الـ VB.Net كحفظ ملف أو فتح ملف أو ...

http://www.codeproject .com (http://www.codeproject .com)


إن شاء الله يفيدك واذا مالقيتي الشيء اللي تبغينه فأنا عندي كود الحفظ والطباعه ومعاينة الطباعة لأني استخدمتهم مسبقا في مشروعي لكن ماأدري وين حاطتهم بالضبط :shiny: واول ماألقاهم بانزلهم لك ان شاء الله .

تحياتي ,,

اسحاق
13-Mar-2008, 07:48 PM
السلام عليكم
al fanarوالظل
ممكن رابط الأكواد الخاصه بالفيجول نت
بأسرع وقت
لأن الرابط مانفتح
ممكن ترسليه مره ثانيه
و
وشكرا