rjef
asked on
update counter file using more than 1 program in VB6
i want to make a program that will run on several pc's made in vb6. i need it to have a button and when the button is clicked the program will go to a file on a pc and get the value in it and add 1 to it then save it again into that file. (so there is always just one number in the file) I want all the programs to do the same thing to the same file. What do you suggest i do to keep the counting file from not losing data or missing a count?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i added this but would like it cleaned up a bit
this seems to work
this seems to work
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Randomize
For CountThem = 1 To 100
DoEvents
Label1.Caption = CountThem
Label1.Refresh
SleepNumber = Int((1000 - 0 + 1) * Rnd + 0)
Sleep (SleepNumber)
DoEvents
MyFile = Dir("c:\FileToOpen\IsItBusy")
If MyFile = "" Then
Open "C:\FileToOpen\IsItBusy" For Output As #2
Close #2
Open "C:\FileToOpen\FileToOpen.txt" For Input As #3
Line Input #3, countit
Close #3
countit = countit + 1
Open "C:\FileToOpen\FileToOpen.txt" For Output As #1
Print #1, countit
Close #1
Kill "C:\FileToOpen\IsItBusy"
Else
CountThem = CountThem - 1
End If
Next CountThem
End Sub
ASKER
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Randomize
For hhh = 1 To 100
Label1.Caption = hhh
Label1.Refresh
sleepnumber = Int((1000 - 0 + 1) * Rnd + 0)
Sleep (sleepnumber)
Open "C:\FileToOpen\FileToOpen.
Line Input #1, countit
Close #1
countit = countit + 1
Open "C:\FileToOpen\FileToOpen.
Print #1, countit
Close #1
Next hhh
End Sub