03-15-2006, 11:55 PM
hello. I've just recently downloaded and installed VB .NET 2005 Express Edition. I'm kinda one of those qbasic hobbiest programmers, except I toyed with Visual Basic for MS-DOS. I'm trying to convert one of my old programs which is a graphing calculator. Problem is, I'm real stuck on how to do that in VB .NET. I see pretty much the things I need to change in the old code, but I need to be able to plot points, i guess in a picture box. All I know is that there's no "PSET" function, I would have to use DrawEllipse instead, setting height and length to 1. There's something about Pen and Color and stuff. Could someone please write or provide a short template that enables one to plot functions? I would appreciate that.
Also, is there a way to change the dimensions of a picturebox, I mean like making it's dimension (-200,-200)-(200,200)...but it doesn't physically change the size of the box. If not, then what can I use as a graphics platform in VB if I want to create a cartesian graph utility?
03-16-2006, 06:02 AM
For graphing, have you considered drawing interconnected lines instead of points?
Also, you can do your own scaling, either by way of Graphics transforms, or simply adding and multiplying values to your graph coordinates.
For example, getting a scale of (-A,-B) to (C,D) would use a bit of interpolation, but does the scaling for you.
For the point X,Y, you'd do
Pt.X = (X + A) / (C + A) * Picbox.Width
Pt.Y = (Y + B) / (D + B) * Picbox.Height
03-16-2006, 02:31 PM
yeah, I'm getting some weird numbers with that. Is there a way to convert relative coordinates to real coordinates? Such as the PMAP command in BASIC? Or is there an actual control or property dealing with that?
Not sure what Pt is supposed to be, but I was plugging those numbers (CORX = pt.x, and CORY as pt.y) into the DrawEllipse(p, CORX, CORY, 1,1) function to plot points.
03-16-2006, 05:18 PM
Um... yes, that should be a transform from an upside down cartesian coordinate system to a picturebox point system, where the point (X, Y) is a cartesian coordinate and (Pt.X, Pt.Y) is the coordinate on the picturebox where that point would appear. :)
Note that you do have to actually put in numbers into that equation, it doesn't work otherwise.
03-17-2006, 01:55 AM
Okay, I have a working model...but i altered what ya gave because the numbers weren't right. I had to toy around with it.
CORX = (-X + A) / (-C + A) * PictureBox1.Width
CORY = (Y + B) / (-D + B) * PictureBox1.Height
Another problem I have is keyboard input for Do loops. There's no "INKEY$" function. Any tips on what to use?
LOOP UNTIL ???? <> ""
Another thing for another project, and I know this sounds retarded but I'm kind of a nubie in VB at least, but how do I randomize the color palette?
I appreciate your help.
03-17-2006, 06:04 PM
Wow... InKey$, eh? Color Palettes! lol :p
You don't use those anymore... instead you use the KeyDown events for the form.
The stuff that you were going to put after the Do Loop would go into the KeyDown event... and that would run until :)
And you cannot change the color palette - you can only change the color that you draw with. :)