Question on program involving X & Y coordinates on Visual Basic 2005

I have to do a program onj Visual Basic Express 2005 with these following instructions:

Write a program in which the user enters the x and y coordinates for two points (A and B) on a graph. Using this information, calculate and display the following information:
a) the slope of the line joining A and B
b) the y-intercept of the line going through A and B
c) The equation of the line going through A and B
d) The midpoint of the line AB

I need help to do this. Im new at doing this kind of stuff and i dont really get what to do. So from the instructions shown above i need to get the answers for a), b), c) and d) can someone explain how i would do the code for it to get the information i need to show. Maybe give me an example or something. Or maybe the actual code. I need all the help i can get. Hope someone can help.
Thanks.

Comments

  • seancampbellseancampbell Pennsylvania, USA
    Isn't being new to VB.Net part of taking a class on it?

    Here's what I suggest:

    --The problem statement asks you to have a user enter an X and Y value for two points. That suggests that you need a means of inputting values, which in Windows Application Programming, generally is a TextBox.

    So you want 4 textboxes, One for x1 (txtX1) and one for y1 (txtY1). Also one for x2 (txtX2) and one for y2 (txtY2).

    --You'll probably need a way to tell them apart, you can use a Label to indicate which is which

    So you want 4 labels, one has Text Property set to X1, X2, Y1, or Y2 depending on what Text Box it's next to.

    --You need to calculate 4 different answers. You will have to have a means for the user to tell the program to calculate something and a means to display the answer to him. Button's take user input in the form of a Click and execute a command when the Click Event is triggered. A Label is a great means of displaying an answer, be sure to set the name property of your labels to something meaningful so you know which one to set.

    So you want 4 buttons, 4 labels. (hint: Double click the button in the designer view and it should open the code view with the cursor inside the Button's Click Event Handler routine)

    Here is how to do each of those calculations in the form of online tutorials:
    A) http://www.algebralab.org/lessons/lesson.aspx?file=Geometry_CoordSlope.xml

    B) http://answers.yahoo.com/question/index?qid=20080109081101AAMOwYC (read first the whole question, and then look at the solution in the best answer)

    C) http://en.wikipedia.org/wiki/Linear_equation (look at 2-point form equation)

    D) http://www.purplemath.com/modules/midpoint.htm

    -----

    Because you are going to need this, and I would hate to hear your using old VB6 methods, here is how you check the user input and convert the String values to Number values...

    [code]
    Dim intNumber as Integer = 0 'Integers hold Whole Number values
    Dim dblNumber as Double = 0.0 'Doubles hold Decimal values

    'assume there is a TextBox1 textbox with userinput in it
    If isNumeric(TextBox1.Text) = True Then
    'The value in TextBox1.Text is a Number
    'Now we can Cast it to Integer or Double
    intNumber = CInt(TextBox1.Text)
    dblNumber = CDbl(TextBox1.Text)
    Else
    'The value in TextBox1.Text is not a Number
    'If we tried to cast with CInt or CDbl the program would crash
    'Let's instead tell the user that he's a damn fool, and to enter
    'numbers:
    MessageBox.Show("You're a damn fool, please enter a numeric value in TextBox1")
    End If
    [/code]

    Happy coding,
    Sean Campbell
    firesickle.com
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion