十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
一般,我都不喜欢做这样报上一条下一条,太专业的数据库操作不适合终端用户。
成都创新互联专注于额济纳网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供额济纳营销型网站建设,额济纳网站制作、额济纳网页设计、额济纳网站官网定制、小程序制作服务,打造额济纳网络公司原创品牌,更为您提供额济纳网站排名全网营销落地服务。
如果必须要做,你可以这样:按排序规则,取到健列表。保存到list中,上下条,只是改变一索引而已。
Imports System.Data.OleDb
Class BindNavigate
Dim cnn As OleDb.OleDbConnection '打开连接略
Dim lst As New List(Of Integer)
Sub New()
lst = New List(Of Integer)
index = -1
Using da As New OleDbDataAdapter("select id from mytable order by abc,def", cnn), tb As New DataTable
da.Fill(tb)
For Each row As DataRow In tb.Rows
Dim n As Integer = row(0)
lst.Add(n)
Next
If tb.Rows.Count 0 Then CurrentIndex = 0
End Using
End Sub
Dim index As Integer Event CurrentIndexChanged()
Property CurrentIndex As Integer
Get
Return index
End Get
Set(ByVal value As Integer)
Dim b As Boolean = value index
index = value
If b Then RaiseEvent CurrentIndexChanged()
End Set
End Property
'当前的键值
ReadOnly Property CurrentValue As Integer
Get
Return lst(index)
End Get
End Property
Sub MoveFirst()
CurrentIndex = 0
End Sub
Sub MovePrevious()
CurrentIndex -= 1
End Sub
Sub MoveNext()
CurrentIndex += 1
End Sub
Sub MoveLast()
CurrentIndex = lst.Count - 1
End Sub
ReadOnly Property BOF
Get
Return CurrentIndex = 0
End Get
End Property
ReadOnly Property EOF
Get
Return CurrentIndex = lst.Count - 1
End Get
End Property
Private Sub Text_CurrentIndexChanged() Handles Me.CurrentIndexChanged
'绑定过程
End Sub
End Class
数据库中记录的存放是无序的,不存在顺序问题。
如果需要顺序,可在查询语句中使用 order by 子句。
加了单引号就是一个常量字符串了,对于每一行都是一样的
像这种放在最前面的字段,order by 1 就可以了
function Newfile as fileinfo
Dim dic As New System.IO.DirectoryInfo("C:\Users\Q\Desktop\数据")
Dim files = dic.GetFiles.OrderByDescending(Function(s) s.CreationTime)
if files.
return files.first
end function
注意引入 system.linq
Function a(s As String) As String
Dim i = s.IndexOf("/")
If i 0 Then
Return s.Substring(0, i)
ElseIf i = 0 Then '第一个字符为"/"
If s.LastIndexOf("/") 0 Then '不只一个"/"
Return s.Substring(0, s.Substring(1).IndexOf("/") + 1)
Else
Return Nothing '只有一个"/"
End If
Else '不含"/"或是空串
Return Nothing
End If
End Function
基本上不出错了