【问题标题】:getting started with VB.netVB.net 入门
【发布时间】:2011-05-03 15:15:35
【问题描述】:

我有几个问题,我正在使用 Visual Basic,我正在编写程序。我对此仍然有些困惑。我知道当您将 Dim x 作为整数或任何您想放在那里的东西时,您就有了开始。现在要调用一个函数,您将其放在 end sub 下方以调用一个函数。我只是对如何调用以及函数中应该包含什么感到困惑。我知道这可能不会,我很抱歉。我不明白这些。

这就是我所拥有的,我正在努力……

Module Module1

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

End Module

我正在努力了解如何做到这一点,如果有人可以解释或有一个可以帮助的网站,谢谢。

好的,这是我必须做的事情之一...在主过程中调用一个函数过程来输入和返回一个名为 x 的双变量变量的值,即直角三角形的宽度。在主过程中第二次调用相同的函数过程来获得一个名为 y 的双变量值,即直角三角形的高度。

【问题讨论】:

  • 你的函数应该做什么?
  • 我觉得令人困惑的是您的问题标题与实际问题之间的联系。你能解释一下吗?
  • 这和client server model有什么关系??它的标题应该是“vb.net 入门”,这个短语你也可以用谷歌搜索...
  • 因为这就是我的章节所说的

标签: .net vb.net


【解决方案1】:

你在正确的轨道上;您的函数需要名称和返回类型。您还需要一个结束函数。

看看这个,我认为它可能有助于您尝试做的事情。

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 

【讨论】:

    【解决方案2】:

    在“Visual Basic 教程”上搜索'net,找到代码对您有意义的页面,复制它,编译它,运行它,修改它,然后重复。从运行代码开始总是更容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-03
      • 1970-01-01
      • 2012-11-15
      • 2010-09-21
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多