⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.bas

📁 这是一个用VB编写的在线考试系统
💻 BAS
字号:
Attribute VB_Name = "Module1"
Option Explicit
Public ik As Integer
Public kaodsk As Integer
Public kaodskt As Integer
Public bytemp As Integer
Sub Main()
ik = 0
Load form3
form3.Visible = True
End Sub
Function readfile(seekid As Integer, fileid As Integer, hao As Integer) As String
'seekid是功能码用来说明本次是何操作
'fileid是文件号说明要对哪个文件进行操作
'hao:备用说明,在seekid为5或2指明要前进或后退多少,0为退2,1就是退3或进1(两行就是进2)
Dim st As String
Dim sa As String * 1
Dim sb As String * 1
Select Case seekid
Case 0
'get next
If Seek(fileid) >= LOF(fileid) Then
readfile = "seek_end"
Exit Function
End If
Do While 1
Get #fileid, , sa
If sa = Chr(16) Then
Get #fileid, , sb
If sb = Chr(17) Then
readfile = st
Seek #fileid, Seek(fileid) + 2
Exit Function
Else
Seek #fileid, Seek(fileid) - 1
End If
End If
st = st & sa
If Seek(fileid) >= LOF(fileid) Then
readfile = st
Exit Function
End If
Loop
Case 1
' go top
Seek #fileid, 1
readfile = readfile(0, fileid, 0)
Exit Function
Case 2
' go -1
If Seek(fileid) = 1 Then
readfile = readfile(0, fileid, 0)
Exit Function
End If
Dim ba As Byte
Dim bb As Byte
Dim bc As Byte
Dim bd As Byte
bc = &H10
bd = &H11
Seek #fileid, Seek(fileid) - 5
Do While 1
If Seek(fileid) = 1 Then
readfile = readfile(0, fileid, 0)
Exit Function
End If
Get #fileid, , ba
If ba = bc Then
Get #fileid, , bb
If bb = bd Then
Seek #fileid, Seek(fileid) + 2
If hao = -1 Then
readfile = readfile(0, fileid, 0)
Exit Function
Else
readfile = readfile(2, fileid, hao - 1)
Exit Function
End If
Else
Seek #fileid, Seek(fileid) - 1
End If
End If
Seek #fileid, Seek(fileid) - 2
Loop
Case 3
'go boot
Seek #fileid, LOF(fileid)
readfile = readfile(0, fileid, 0)
Exit Function
Case 5
'go N
If hao = 0 Then
readfile = readfile(0, fileid, 0)
Exit Function
End If
Dim x As Integer
For x = 1 To hao * 2
readfile = readfile(0, fileid, 0)
If readfile = "seek_end" Then
Exit Function
End If
Next
readfile = readfile(0, fileid, 0)
Exit Function
'get all or next_all
Case 9
If hao = 1 Then Seek #fileid, 1
Dim stra, strb As String
stra = ""
strb = ""
stra = readfile(0, fileid, 0)
Do While 1
strb = strb & stra & Chr(16) & Chr(17) & Chr(13) & Chr(10)
stra = readfile(0, fileid, 0)
If stra = "seek_end" Then
readfile = strb
Exit Function
End If
Loop
End Select
End Function
Function textpass(passtext As String) As String
Dim p, i, j As Integer
Dim st(3) As String
p = Len(passtext)
For i = 1 To p
If i = p Then
st(0) = Str(Asc(Mid(passtext, i, 1)))
st(1) = Str(Asc(Mid(passtext, 1, 1)))
Else
st(0) = Str(Asc(Mid(passtext, i, 1)))
st(1) = Str(Asc(Mid(passtext, i + 1, 1)))
End If
st(0) = Str(Val(st(0)) + Val(st(1)))
For j = 1 To Len(st(0))
st(2) = Str(Val(Mid(st(0), j, 1)) * 20)
st(3) = st(3) & st(2)
Next
Next
textpass = Trim(st(3))
End Function
Function jiao(name As String, pass As String) As Integer
Open App.Path & "\admin.dat" For Binary As #22
Dim tmname, tmpass As String
Do While 1
tmname = readfile(0, 22, 0)
tmpass = readfile(0, 22, 0)
If tmname = "seek_end" Then Exit Do
If textpass(name) = tmname And textpass(pass) = tmpass Then
jiao = 1
Close #22
Exit Function
End If
Loop
Close #22
jiao = 0
End Function
Function findj(name As String, fileid As Integer) As Integer
Dim tmname, tmpass As String
Dim ipe As Integer
ipe = 0
Do While 1
ipe = ipe + 1
tmname = readfile(0, fileid, 0)
If tmname = "seek_end" Then Exit Do
If textpass(name) = tmname Then
findj = ipe
Close #fileid
Exit Function
End If
tmpass = readfile(0, fileid, 0)
Loop
findj = 0
Close #fileid
End Function
Function delj(name As String, fileid As Integer, hs As String) As Integer
Dim s, sa As String
sa = ""
delj = 0
Do While 1
s = readfile(0, fileid, 0)
If textpass(name) = s Then
If hs = "" Then
s = readfile(0, fileid, 0)
s = readfile(0, fileid, 0)
delj = 12
Else
sa = sa & s & Chr(16) & Chr(17) & Chr(13) & Chr(10)
sa = sa & textpass(hs) & Chr(16) & Chr(17) & Chr(13) & Chr(10)
delj = 13
s = readfile(0, fileid, 0)
s = readfile(0, fileid, 0)
End If
End If
If s = "seek_end" Then
Exit Do
End If
sa = sa & s & Chr(16) & Chr(17) & Chr(13) & Chr(10)
Loop
Close #fileid
Open App.Path & "\..\jiao.dat" For Output As #fileid
Print #fileid, Left(sa, Len(sa) - 2)
Close #fileid
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -