kapilhvara
MIS
Hi Guys i am currently new to VB and am studying from a book i followed the instructions on the book and get a compile error: End of statement expected. The Form is ment to show a list of fonts. i get a compile error on e.Graphics.DrawString(strfontname, fnt, br, 0, intycoord.
The code is as follows
Private Sub exercise1_2_paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
'Set the y co-ordinate'
Dim intycoord As Integer = 0
'create a black solidbrush'
Dim br As SolidBrush = New SolidBrush(Color.Black)
'iterate through the fontfamily.families'
Dim i As Integer
For i = 0 To FontFamily.Families.Length - 1
Dim fs As FontStyle = FontStyle.Regular
'check whether regular is available'
If Not (FontFamily.Families(i).IsStyleAvailable(FontStyle.Regular)) Then fs = FontStyle.Italic
'check wether italic style is available'
If Not (FontFamily.Families(i).IsStyleAvailable(FontStyle.Italic)) Then fs = FontStyle.Bold
'if bold isn't available give up'
If Not (FontFamily.Families(i).IsStyleAvailable(FontStyle.Bold)) Then
GoTo NextFont
End If
' create a font object and draw the font name'
Dim fnt As Font = New Font(FontFamily.Families(i).Name, 12, fs)
Dim strfontname As String = FontFamily.Families(i).Name e.Graphics.DrawString(strfontname, fnt, br, 0, intycoord)
' increase the y coordinate by the font height'
intycoord += fnt.Height
NextFont:
Next
End Sub
End Class
Any feed back would be much appricated
Thanks
The code is as follows
Private Sub exercise1_2_paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
'Set the y co-ordinate'
Dim intycoord As Integer = 0
'create a black solidbrush'
Dim br As SolidBrush = New SolidBrush(Color.Black)
'iterate through the fontfamily.families'
Dim i As Integer
For i = 0 To FontFamily.Families.Length - 1
Dim fs As FontStyle = FontStyle.Regular
'check whether regular is available'
If Not (FontFamily.Families(i).IsStyleAvailable(FontStyle.Regular)) Then fs = FontStyle.Italic
'check wether italic style is available'
If Not (FontFamily.Families(i).IsStyleAvailable(FontStyle.Italic)) Then fs = FontStyle.Bold
'if bold isn't available give up'
If Not (FontFamily.Families(i).IsStyleAvailable(FontStyle.Bold)) Then
GoTo NextFont
End If
' create a font object and draw the font name'
Dim fnt As Font = New Font(FontFamily.Families(i).Name, 12, fs)
Dim strfontname As String = FontFamily.Families(i).Name e.Graphics.DrawString(strfontname, fnt, br, 0, intycoord)
' increase the y coordinate by the font height'
intycoord += fnt.Height
NextFont:
Next
End Sub
End Class
Any feed back would be much appricated
Thanks