VB.Net

  • Thread starter Thread starter Tony Viscio
  • Start date Start date
T

Tony Viscio

Hi, my name is tony

I'm new to VB.Net I'm having trouble writing a Function
Procedure For
Distance = Speed * Time
Speed = Distance / Time
Time = Distance / Speed

With two textboxes, one label, one button to calculate,
I'm still having trouble calling on the procurers. I get a
variety of different answers as I change it but none are
close.
If any body has any suggestions or could recommend a good
book would appreciate.
I'm in class at BCCC but the teacher is new at it And all
the tutors have only had VB.6 And seem to be confused on
this, I was doing good up till know, Need any help or
suggestions any may have that could.
 
Tony Viscio said:
I'm new to VB.Net I'm having trouble writing a Function
Procedure For
Distance = Speed * Time
Speed = Distance / Time
Time = Distance / Speed

Hi Tony... we can probably figure out what's going wrong (and make
suggestions) if you post the code you have so far.
 
maybe something like this
code not tested

private function Distance(speed as double, time as double) as double
return (speed * time)
end function

private function Speed(distance as double, time as double) as double
return (distance/time)
end function

but the problem is how wil you be calling these functions, how wil the 1
button decide w function to use. if you could give more info on w you want
to do en how you want to do it, i'm sure you'll get better help here.
 
Hi Tony,

I did make an example for you, but to be sure you learn something from it, I
did not check if it did work right. I could be much nicer, but with only 1
button and 2 textboxes that is difficult.

I would check it good if I was you, because I really did not check it.
Just a way how you could use the code.


\\\\
'Distance = Speed * Time
'Speed = Distance / Time
'Time = Distance / Speed
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Button1.Text = "Distance"
Me.TextBox1.Text = "Speed"
Me.TextBox2.Text = "Time"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If IsNumeric(Me.TextBox1.Text) And IsNumeric(Me.TextBox1.Text) Then

Select Case Me.Button1.Text
Case "Distance"
Me.TextBox1.Text = (CDbl(Me.TextBox1.Text) *
CDbl(Me.TextBox2.Text)).ToString
Me.TextBox2.Text = "Time"
Me.Button1.Text = "Speed"
Case "Speed"
Me.TextBox2.Text = (CDbl(Me.TextBox1.Text) /
CDbl(Me.TextBox2.Text)).ToString
Me.TextBox1.Text = "Distance"
Me.Button1.Text = "Time"
Case "Time"
Me.TextBox1.Text = (CDbl(Me.TextBox1.Text) /
CDbl(Me.TextBox2.Text)).ToString
Me.TextBox2.Text = "Time"
Me.Button1.Text = "Distance"
End Select
Else
If Not IsNumeric(Me.TextBox1.Text) Then
Me.TextBox1.Text = "Error"
Else
Me.TextBox2.Text = "Error"
End If
End If
End Sub
////
 
Hi Eric,

That was why it was an challenge for me to make that example.
but the problem is how wil you be calling these functions, how wil the 1
button decide w function to use. if you could give more info on w you want
to do en how you want to do it, i'm sure you'll get better help here.

I had to think on my bicycle, for a real Belgian you must see that now also
before you.

Cor
 
hi cor :)

your example will work (at first sight, didn't test it myself) and i don't
think there are many possibilities w 2 txt's and a button, but is it of any
use?

if he where to use 3 textboxes and a button you could check w one was left
open .... the functionallity would increase a lot

thats why i asked tony to think about it himself, is this really w he
wants??

btw
mental image of a dutch person riding a bicycle in the rain ;p
 
Back
Top