开发者

getting started with VB.net

I have a few questions I am working with visual basic and i am doing writing procedures. I am still a little bit confused about this. I know you have your beginning when you do your Dim x as integer or whatever you want to put there. Now to call a function you drop below the end sub to call a function. I am just confused on how to call and what should be in the function. I know this might not make since and i am sorry. I am not understanding any of this.

s开发者_如何学运维uch as this is what I have and I am working on...

Module Module1

Sub Main()
    Dim x As Double
    Dim y As Double
    Console.WriteLine()
End Sub
Private Function 

End Module

I am trying to understand how to do this is all so if anyone can explain or has a website that will help thanks.

ok here is one of the things i have to do...Inside the main procedure call a function procedure to input and return a value for a double variable called x, the width of a right triangle. Inside the main procedure call the same function procedure a second time to get a value for a double variable called y, the height of a right triangle.


You are on the right track; your function needs a name and a return type. You need an End Function as well.

Take a look at this, I think it might help as a guideline for what you are trying to do.

Module Module1  
    Sub Main()     
        Dim x As Double     

        ' Here we call the function below; and it's value will be returned and stored 
        ' in the variable 'y'
        Dim y As Double = GetValue()

        ' Now we're going to display y so we can see that it worked correctly
        Console.WriteLine(y) 

        'So the console window doesn't close before you can see it
        Console.Read()       
    End Sub 

    ' This is a function that we can call from other parts of our code
    ' It's name is GetValue - we call it by it's name (y = GetValue())
    ' Double is what it returns; double is a big, precise number
    ' Private referes to who can call this function (I wouldn't worry about that too much now)
    ' You need to end the function with 'End Function'.  'Return' tells it to leave the function and give back the value specified (4.0 in this case)
    Private Function GetValue() As Double  
        Return 4.0
    End Function
End Module 


Search the 'net on "Visual Basic Tutorial", find a page where the code makes sense to you, copy it, compile it, run it, modify it, and repeat. It is always easier to start with a running bit of code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜