作者 主題: vs 2008 好用的  (閱讀 4437 次)

0 會員 與 1 訪客 正在閱讀本文。

小徒兒

  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
vs 2008 好用的
« 於: 2008-09-22 12:11 »
**linklabel (text)

linklabel1.linkvisited = true

** system.diagnostics.process.start

system.diagnostics.process.start ("IExplore.exe" , "http://www.microsoft.com/taiwan/learning/books/defaults.mspx")

system.diagnostics.process.start( "Winword.exe", "c:\myletter.doc")


**timer


**debugging

代碼: [選擇]
try
  picturebox1.image = system.drawing.bitmap.fromfile ("d:\fileopen.bmp")

catch when err.number = 53 'can not find file
 msgbox ("please put cd in the cd rom reader")
     
     try
         picturebox1.image = system.drawing.bitmap.fromfile("d:\fileopen.bmp")
     catch
         msgbox ("can not use, please check the cd rom function!")
         button1.enabled = false
     end try
catch when err.number = 7 'out of memory
 msgbox ("is this really jpeg",, err.description)
catch
  msgbox ("system loading file error", , err.description)



***dynamic array

dim temperature() as single

dim days as short
days = inputbox ("how many days", "build array")
redim temperatures (Days -1)


for i = 0 to ubound (temperatures)
   temperatures(i) = inputbox (prompt, title)
next



finally
end try


代碼: [選擇]

try
    err.raise(61)
catch when err.number = 61
   msgbox ('error: disk is full")
end try



***controls
dim ctrl as control
for each ctrl in controls
    ctrl.left = ctrl.left + 25

next


***file writer
savefiledialog1.filter = "text files (*.txt)|*.txt"
savefiledialog1.showdialog()
if savefiledialog1.filename <> "" then
 fileopen(1, savefiledialog1.filename, openmode.output)
 printline(1, txtnote.text) ' copy text to disk
 fileclose(1)
end if


***CLASS
Public Class Person
    Private Name1 As String
    Private Name2 As String


    Public Property FirstName() As String

        Get
            Return Name1
        End Get

        Set(ByVal value As String)

            Name1 = value
        End Set

    End Property

    Public Property Lastname() As String
        Get
            Return Name2

        End Get

        Set(ByVal value As String)
            Name2 = value

        End Set
    End Property

    Public Function Age(ByVal Birthday As Date) As Integer
        Return Int(Now.Subtract(Birthday).Days / 365.25)

    End Function

End Class

**USE CLASS
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Employee As New Person
        Dim DOB As Date

        Employee.FirstName = TextBox1.Text
        Employee.Lastname = TextBox2.Text
        DOB = DateTimePicker1.Value.Date

        MsgBox(Employee.FirstName & " " & Employee.Lastname _
               & "is " & Employee.Age(DOB) & "years old")
    End Sub
End Class


***PRINT
Imports System.Drawing.Printing

Public Class Form1

    'Sub for printing text
    Private Sub PrintText(ByVal sender As Object, _
      ByVal ev As PrintPageEventArgs)
        'Use DrawString to create text in a Graphics object
        ev.Graphics.DrawString(TextBox1.Text, New Font("Arial", _
          11, FontStyle.Regular), Brushes.Black, 120, 120)
        ' Specify that this is the last page to print
        ev.HasMorePages = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Print using an error handler to catch problems
        Try
            ' Declare PrintDoc variable of type PrintDocument
            Dim PrintDoc As New PrintDocument
            AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
            PrintDoc.Print()   'print text
        Catch ex As Exception  'catch printing exception
            MessageBox.Show("Sorry--there is a problem printing", ex.ToString())
        End Try
    End Sub
End Class




« 上次編輯: 2008-09-22 14:45 由 小徒兒 »