-1

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.

such 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.

4
  • What is your function supposed to do? Commented May 3, 2011 at 15:18
  • What I find confusing is the connection between the title of your question and the actual question. Can you explain? Commented May 3, 2011 at 15:19
  • What does this have to do with client server model?? It should be titled 'getting started with vb.net', a phrase you can just as well google for... Commented May 3, 2011 at 15:19
  • Cause that is what my chapter says Commented May 3, 2011 at 15:22

1 Answer 1

5

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 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.