首先,让我们看看我的代码:
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
。我得到了这个结果:
但我希望结果是:
我尝试了以下链接和方法:
答案 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()将不起作用,它将保持“无”
示例: