I don't know much about drawing graphics from strings, but you are getting this error because you are passing a System.EventArgs object when the function is looking for a PaintEventArgs object. You'll need to create a PaintEventsArgs object and then pass it.
On Mon, 21 Feb 2005 04:35:03 -0000, vjjtaal <[EMAIL PROTECTED]> wrote: > > > Hi, I'm just getting started on programming with VB .NET, with not > much earlier experience (some Assembler in the distant past and a bit > of Turbo Basic, for all the use that is). After dashing through the > Step by Step book, I'm itching to get some ideas into code, but I am > still struggling to understand many of the basic concepts. > > I want to convert some text into a graphic array. It looks like I can > do something using the DrawString method but I can't figure out the > example in the Help file, which is supposed to write text as graphics > to the screen. (After I sort that out, mapping the bits to an array is > my next step.) > > The example routine itself is moderately clear even to me: > > Public Sub DrawStringRectangleF(e As PaintEventArgs) > ... > (various Dims: drawString As String, drawFont As New Font, drawBrush, > x, y, width, height, drawRect as New Rectangle, blackPen: I hope > these are obvious) > ... > e.Graphics.DrawRectangle(blackPen, x, y, width, height) > e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect) > EndSub > > My problem is how do I activate that darned routine. I've tried coding > a button as follows: > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) > Call DrawStringRectangleF(e) > End Sub > > But this gives me a 'casting error' at runtime. Can anyone tell me > what I'm doing wrong? Am I forgetting to import or initiate some > library? Am I calling the Public sub the wrong way? > > I'll be mightily glad of any help. Vic > > '// ======================================================= > Rules : http://ReliableAnswers.com/List/Rules.asp > Home : http://groups.yahoo.com/group/vbHelp/ > ======================================================= > Post : [email protected] > Join : [EMAIL PROTECTED] > Leave : [EMAIL PROTECTED] > '// ======================================================= > > Yahoo! Groups Links > > > > > -- --- Don Roberts - [EMAIL PROTECTED] http://www.drscripting.com http://www.freakingidiot.com '// ======================================================= Rules : http://ReliableAnswers.com/List/Rules.asp Home : http://groups.yahoo.com/group/vbHelp/ ======================================================= Post : [email protected] Join : [EMAIL PROTECTED] Leave : [EMAIL PROTECTED] '// ======================================================= Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/vbhelp/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
