写入文本框仍然失败 - Visual Basic 2010

时间:2013-07-31 08:34:48

标签: vb.net visual-studio-2010 textbox

道歉,如果这是一个容易出错的错误,对于VB来说是一个新手,但不确定我哪里出错了。我的代码产生的结果我将在过程结束时写入文本框。这是我目前的代码:

Public Class Form1
    Public Sub ButtonInput_Click(ByVal sender As System.Object, ByVal e As     System.EventArgs) Handles ButtonInput.Click
        Try
            'information irrelevant to question here..

            MainMethod.Main()

            TextBoxbf.AppendText(bestGlobalFitness.ToString("F4"))
            TextBox0.Text = bestGlobalPosition(0)
            TextBox1.AppendText(bestGlobalPosition(1).ToString("F4"))
            TextBox2.AppendText(bestGlobalPosition(2).ToString("F4"))
            TextBox3.AppendText(bestGlobalPosition(3).ToString("F4"))
            TextBox4.AppendText(bestGlobalPosition(4).ToString("F4"))
            TextBox5.AppendText(bestGlobalPosition(5).ToString("F4"))
            TextBox6.AppendText(bestGlobalPosition(6).ToString("F4"))

        Catch ex As IndexOutOfRangeException
            Console.WriteLine("IndexOutOfRangeException caught")
        End Try
    End Sub
End Class

正如您所看到的,我已经尝试了TextBox.Text和TextBox.AppendText方法,但似乎都没有工作。有点奇怪的是第一行TextBoxbf.AppendText(bestGlobalFitness.ToString(“F4”))确实有效..

以下是在模块中输入bestGlobalPosition和bestGlobalFitness的方法:

Module MainMethod
    Public bestGlobalFitness As Double
    Public bestGlobalPosition([Dim] - 1) As Double
Public Sub Main()
    Try
        Dim bestGlobalPosition([Dim] - 1) As Double
        bestGlobalFitness = Double.MaxValue

        'rest of method here..

        Console.Write("Final best fitness = ")
        Console.WriteLine(bestGlobalFitness.ToString("F4"))
        For i As Integer = 0 To bestGlobalPosition.Length - 1
            Console.Write("x" & i & " = ")
            Console.WriteLine(bestGlobalPosition(i).ToString("F4") & " ")

我真的看不出我错在哪里 - 任何帮助都会非常感激!

0 个答案:

没有答案