Dim str1 As String
str1 = \"This is a good day.\"
str1 = Replace(str1, \"good\", \"great\")
MsgBox str1
Dim fs As FileSystemObject
Dim f As TextStream
Set fs = New FileSystemObject
Set f = fs.OpenTextFile(\"c:\\test.txt\", ForAppending, True)
f.WriteLine \"This is a test.\"
f.Close
Dim fs As FileSystemObject
Dim f As TextStream
Set fs = New FileSystemObject
Set f = fs.OpenTextFile(\"c:\\test.txt\")
Do While Not f.AtEndOfStream
MsgBox f.ReadLine()
Loop
f.Close
' This code loads a bitmap file into a Picture control
Private Sub cmdLoadBitmap_Click()
Dim bmp As Bitmap, filename As String
filename = App.Path & \"\\test.bmp\"
Set bmp = LoadPicture(filename)
Set picCanvas.Picture = bmp
End Sub
Private Sub cmdDraw_Click()
Dim pen As Pen, bitmap As Bitmap
Dim g As Graphics, x, y As Integer
x = 5
y = 5
Set bitmap = picCanvas.Picture.Clone()
Set g = Graphics.FromImage(bitmap)
Set pen = New Pen(vbBlue)
g.DrawLine pen, x, y, x + 100, y + 100
picCanvas.Picture = bitmap
End Sub
' This code centers the form on the screen
Private Sub CenterForm()
Dim w As Integer, h As Integer
w = Screen.Width / 2 - Width / 2
h = Screen.Height / 2 - Height / 2
Move w, h
End Sub
' This code hides the control named TextBox1
Private Sub HideControl()
TextBox1.Visible = False
End Sub