'Ìîäóëü ñîçäàâàë êîãäà òîëüêî íà÷èíàë îñâàèâàòü vb6. Ñ òåõ ïîð íè÷åãî íå ìåíÿë. Þçàþ - ðàáîòàåò.
'Æåëàòåëüíî èñïðàâèòü íîìåð êàíàëà ôàéëà. Íå èçìåíÿòü Ìåòîäû íà íåîïèñàííûå â òèïîâîì ðóêîâîäñòâå ïî vb.
Option Explicit
Dim stats(255) As String
Dim dry As Boolean
Dim hp As String
Sub setStatics() 'Ñîõðàíåíèå ïàðàìåòîðîâ (Âûçûâàòü ïðè âûãðóçêå)
On Error Resume Next
If dry Then
Dim ssi As Integer
Open App.Path + hp + "Static.txt" For Output As 1
For ssi = 0 To 255
Print #1, stats(ssi)
Next
Close #1
dry = False
End If
End Sub
Sub getStatics() 'Çàãðóçêà ïàðàìåòðîâ (Âûçûâàòü èç sub_main / sub_formX_load)
On Error Resume Next
hp = IIf(InStr(1, App.Path, "\") > 0, "\", "/") 'èíà÷å íå ðàáîòàåò ïîä miniPE (è environ$() òàì íåòó)
Dim gsi As Integer
If checkFileLocation(App.Path + hp + "Static.txt") Then
Open App.Path + hp + "Static.txt" For Input As 1
For gsi = 0 To 255
Line Input #1, stats(gsi)
Next
Close #1
dry = False
Else
'çàãðóçèòü ïàðàìåòðû ïî-óìîë÷àíèþ îòêóäà-íèáóäü
End If
End Sub
Function checkFileLocation() 'íå òðîãàòü
On Error Resume Next
If Dir(App.Path + hp + "Static.txt") = "" Then
Open App.Path + hp + "Static.txt" For Binary As 1
Close #1
checkFileLocation = IIf(Dir(App.Path + hp + "Static.txt") = "", False, True)
Else
checkFileLocation = True
End If
End Function
Function getstatvalue(Index As Long) As String 'âîçâðàùàåò çíà÷åíèå àðãóìåíòà íîìåð <Index>
getstatvalue = stats(Index)
End Function
Sub setstatvalue(Index As Long, value As String) 'íàçíà÷àåò çíà÷åíèå <value> àðãóìåíòó íîìåð <Index>
dry = True
stats(Index) = value
End Sub
Dim CN as New Connection
On error resume next
Set CN = New Connection
CN.Open "Driver=Microsoft dBase Driver (*.dbf);DBQ=" & MainPath
if CN.State = 1 then
'приконекчен
else
'не законектился
End
End if
"Select * from testDBF"
On error resume next
Set RS = CN.Execute("Select * from testDBF")
If ERR=0 then
While Not RS.EOF
debug.Print RS!RegID & ". " & RS!FIO
RS.MoveNext
Wend
Else
MsgBox Err.Description
End if
On error resume next
CN.Execute "UPDATE testDBF SET Dozvon = 1 WHERE RecID=4"
"SELECT * FROM testDBF WHERE Dozvon=1"
"SELECT * FROM testDBF WHERE Dozvon=0"
CN.Open "Driver=Microsoft dBase Driver (testDBF.dbf);DBQ=" & App.Path
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 60