Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error in VB Form

Status
Not open for further replies.
Jul 1, 2005
4
GB
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
 
Thanks for your help mate seems to have worked moved the e.graphics on the other line but in the book it is on one line, Thats not good?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top