Di bawah ini merupakan contoh print left - center - right pada PictureBox, seperti pada gambar di bawah ini:
Gambar - VB6 Print Left Center Right Align PictureBox |
Option Explicit
'-------------------------------------------------------------------------
'http://khoiriyyah.blogspot.com
'-------------------------------------------------------------------------
'Print right align pada objek PictureBox
Private Sub PrintRightAlign(ByVal Teks As String, pic As PictureBox)
With pic
.CurrentX = pic.ScaleWidth - pic.TextWidth(Teks)
pic.Print Teks
End With
End Sub
'Print center pada objek PictureBox
Private Sub PrintCenter(ByVal Teks As String, pic As PictureBox)
With pic
.CurrentX = (pic.ScaleWidth - pic.TextWidth(Teks)) / 2
pic.Print Teks
End With
End Sub
'Print left pada objek PictureBox
Private Sub PrintLeft(ByVal Teks As String, pic As PictureBox)
With pic
pic.Print Teks
End With
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
End Sub
'Contoh print left align
Private Sub cmdLeft_Click()
Static i As Long
i = i + 1
Call PrintLeft(i, Picture1)
End Sub
'Contoh print center
Private Sub cmdCenter_Click()
Static i As Long
i = i + 1
Call PrintCenter(i, Picture1)
End Sub
'Contoh print right
Private Sub cmdRight_Click()
Static i As Long
i = i + 1
Call PrintRightAlign(i, Picture1)
End Sub
Download: vb6_print_center_right_left.zip