如何在VB.net中将String转换为代码?

时间:2017-02-21 11:36:24

标签: vb.net

首先,让我们看看我的代码:

package inlamningsuppgift_arSorterad;

import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class ifSorted {

    public static void main(String[] arg) {
        LinkedList a = new LinkedList();
        Scanner sc = new Scanner(System.in);
        System.out.println("Input your numbers, end with the letter \\n");

        while (sc.hasNextDouble())
            a.add(sc.nextDouble());

        if (ifSorted(a))
            System.out.println("List is sorted");
        else
            System.out.println("List is not sorted");
    }

    private static boolean ifSorted(LinkedList a) {
        Collections.sort(a);

        return a;
    }
}

假设Private Sub FormLoad(sender As Object, e As EventArgs) Handles MyBase.Load txtMDF.Text = My.Settings.MDF End Sub 的字符串值为My.Settings.MDF。我得到了这个结果:

Image 1

  

但我希望结果是:

Image 2

我尝试了以下链接和方法:

1 个答案:

答案 0 :(得分:2)

正如ProGamer建议的那样,

首先

  

保存My.Settings.MDF字符串=无

第二

  

按如下方式编辑代码:

Private Sub FormLoad(sender As Object, e As EventArgs) Handles MyBase.Load

    If My.Settings.MDF = "None" Then
        txtMDF.Text = Application.StartupPath + "\MyDB.mdf"
    Else
        txtMDF.Text = My.Settings.MDF
    End If
    txtMDF.Text = My.Settings.MDF

End Sub

<强>第三

  

将以下代码添加到YourFormClose_Event

Private Sub FormClosing(sender As Object, e As CancelEventArgs) Handles Me.Closing
    My.Settings.MDF = txtMDF.Text
    My.Settings.Save()
End Sub
  

并且请注意,您应该从“MDF设置”中的“范围下拉”中选择“用户”而不是“应用程序”,否则My.Settings.Save()将不起作用,它将保持“无”

示例:

enter image description here