1

我正在尝试提出一个功能,该功能将允许用户分别按下按钮 BACK 和 NEXT 更改数据。

我正在使用此代码:

         CounterID = IdArray.Length 'array of IDs

        determinator = CounterID 'determining which index is active and putting it on the top of array

        If Ident = 1 Then ' if button back is pressed
            determinator = determinator + 1
            If determinator <= CounterID Then
                'some actions
            End If


        Else
            determinator = determinator - 1
            If determinator >= 0 Then
                'some actions
            End If
        End If

它确实有效。但部分。我的问题是,每当按下按钮时,DETERMINATOR 变量的值就会再次分配给最大长度。

有什么办法可以避免重新分配这个变量并让它只发生一次?

4

1 回答 1

1

您也许可以使用会话变量,如下所示:

If Session("determinator") <> Nothing Then 
  determinator = Session("determinator")
else
  CounterID = IdArray.Length 'array of IDs
  determinator = CounterID
  Session("determinator") = determinator
end if

您可能希望根据 IsPostBack 执行此操作。

于 2013-09-28T18:26:38.910 回答