我需要输出与休息有关的随机数。所以选择一个我需要生成一个随机数,没有连续两次重复的数字。我知道你必须存储以前的值,但不知道从哪里开始。这是我的代码。
d = InputBox(Prompt:="Enter file path", Title:="Please enter the file path", Default:="File Location")
Select Case StrPtr(d)
Case 0
Exit Sub
Case Else
Dim cnn As Object
Dim lngRow As Long
Dim lngID As Long, LR As Long, Upd As Long
Dim strID As String
LR = ThisWorkbook.Worksheets("Update").Range("BN" & Rows.Count).End(xlUp).Row
Upd = LR - 1
lngRow = 2
Set cnn = CreateObject("ADODB.Connection")
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=d"
答案 0 :(得分:1)
prevIndex不能在方法内部,保持在类级别。
private int prevIndex = -1;
private String pickDefaultResponse() {
int index = 0;
do {
index = randomGenerator.nextInt(defaultResponses.size());
} while( index == prevIndex );
prevIndex = index;
return defaultResponses.get(index);
}