System results in NOT RESPONDING state. I want to have an infinite loop till end button is pressed. Through looping, I want to monitor few files. I used if, for, do, while, until , but none of them resulted in a fruitful way. Can anyone plz help me how I can achieve such looping. Plz help with examples. Thanks in advance. My code can be viewed here: http://www.codeproject.com/script/Forums/View.aspx?fid=1646&msg=2467756[^]
arp_059
Posts
-
problem in looping: -
Continuous file monitoring problemI am basically an electronics student. I am currently developing a vb code to control multiple devices using bluetooth. I am making use of vb here. I am a very beginner in vb and dont have much knowledge. Please help me with examples. Problem: Below, I have provided the code which I developed for my project. It monitors few text files located in C:\ directory and based on that, the relevant code is sent through parallel port which I use to further purposes. The problem occurred that I need to monitor those files. I used loop, do, if, goto, while statements. Till the end button is pressed, it needs to monitor the existence of files. All the statements resulted in "NOT RESPONDING" state. Can anyone please help me for that. I just want my program to loop continuously from end to beginning till the end button(command2) is pressed. Then I used a check button and used if command, it also did not work. Here is the code I wrote till now -----------------------------------
Private Sub Command1_Click() ' following sections to read file line obtained from http://www.codeguru.com/forum/archive/index.php/t-315872.html Dim strFile As String Dim PortAddress As Integer 'Dim iFile As Integer Dim strContent As String Dim strContent2 As String Dim strContent3 As String Dim strContent4 As String PortAddress = &H378 'TO Do Add code here to put a filename with path in strFile Label1.Caption = "light is off" 'display status Label3.Caption = "fan is off" 'display status file1 = "c:\lighton.txt" file2 = "c:\lightoff.txt" file3 = "c:\fanon.txt" file4 = "c:\fanoff.txt" 'iFile = FreeFile '1=lighton.txt 2=lightoff.txt 3=fanon.txt 4=fanoff.txt 'restart: Do If (Len(Dir$(file1)) <> 0) Then 'lighton.txt file existance check For j = 1 To 255 Close #j Next j Open "c:\lighton.txt" For Input As #1 'The following will read the first line from the file Line Input #1, strContent ' read 1st line in the file Close #1 ' close file If (strContent = "light on") Then 'check validity of file Label1.Caption = "light is on" 'display status Value = Inp(PortAddress) Value = Value Or &HF 'make lsbs high Out PortAddress, Value 'output the value End If For i = 1 To 5 If (Len(Dir$(file2)) <> 0) Then 'lighton.txt file existance check For j = 1 To 255 Close #j Next j Open "c:\lightoff.txt" For Input