-
Graphics
Load a picture
VB6
Picture1.Picture = LoadPicture(path)
VB7
Dim img As Image = Image.FromFile(path)
Picture1.Image = img
Load a icon
VB6
Me.Icon = LoadPicture(path)
VB7
Dim ico As New Icon(path)
Me.Icon = ico
-
File I/0
Read from a file
VB6
Open path For Input As #1
Line Input #1, buffer
Close #1
VB7
Dim fs As FileStream = File.Open(path, FileMode.OpenOrCreate, _ FileAccess.Read)
Dim sr As New StreamReader(fs)
Buffer = sr.ReadLine
sr.Close
Write to a file
VB6
Open path For Output As #1
Write #1, buffer
Close #1
VB7
Dim fs As FileStream = File.Open(path, FileMode.OpenOrCreate, _
FileAccess.Write)
Dim sr As New StreamWriter(fs)
sr.Write(buffer)
sr.Close
-
Errors
Check for an error
VB6
On Error Goto errhandler
...
errhandler:
MsgBox(err.Description)
VB7
Try
...
Throw New Exception("error description goes here")
...
Catch e as Exception
MsgBox(e.Description)
End Try
-
Events
Handling an event
In VB7, there is a new keyword called AddHandler. AddHandler makes handling events a snap.
AddHandler object.event, AddressOf procedure
No comments:
Post a Comment