Visual Studio help (1 Viewer)

G

Gavvvvvin

Guest
Can someone please tell me what is wrong with this line:

Console.WriteLine("Flow rate = (0)", flowequation(waterheight, maxflowrate, As double))

It has the As underlined and says an expression is expected. Yeah I have no idea what I'm talkin about :confused:
 

ianc

physics is phun!
Joined
Nov 7, 2005
Messages
618
Location
on the train commuting to/from UNSW...
Gender
Male
HSC
2006
I'm not entirely sure either, but just looking at that the syntax looks a bit strange. The As double is not an argument that you're passing to the flowequation function, so shouldn't it be outside the brackets?

Perhaps your code should look like this:

Console.WriteLine("Flow rate = (0)", flowequation(waterheight, maxflowrate) As double)

Hope this helps!!
 
G

Gavvvvvin

Guest
thankd i'ved managed to solve that problem now :p

But I do have a new problem...how do I make the program check whether or not a number has been entered instead of say text?
 

ianc

physics is phun!
Joined
Nov 7, 2005
Messages
618
Location
on the train commuting to/from UNSW...
Gender
Male
HSC
2006
Allows only numbers to be entered in a text box
Code:
'put this code in the keypress event of the textbox

If e.KeyChar.IsNumber(e.KeyChar) = False Then[INDENT]e.Handled = True
[/INDENT]End If
hope this is what you're after!

edit: actually, this isn't what you asked for but it may be useful.

Perhaps you could do an ASCII check on the string? I think ASCII codes for numbers are 48-57. I did this in a program recently, but I don't think I've still got the source code...
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top