Click here to Skip to main content
15,914,111 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: problem in looping: Pin
Dave Kreskowiak17-Mar-08 7:19
mveDave Kreskowiak17-Mar-08 7:19 
Generaldate function problem Pin
soniasan15-Mar-08 11:01
soniasan15-Mar-08 11:01 
GeneralRe: date function problem Pin
Colin Angus Mackay15-Mar-08 12:26
Colin Angus Mackay15-Mar-08 12:26 
Questiondynamic crytal report - without DSN ? Pin
sejal_tank15-Mar-08 9:04
sejal_tank15-Mar-08 9:04 
AnswerRe: dynamic crytal report - without DSN ? Pin
Mycroft Holmes15-Mar-08 21:33
professionalMycroft Holmes15-Mar-08 21:33 
QuestionK8055 USB Experimental Interface Board Pin
CocaColaBoy15-Mar-08 6:35
CocaColaBoy15-Mar-08 6:35 
GeneralRe: K8055 USB Experimental Interface Board Pin
Dave Kreskowiak17-Mar-08 7:15
mveDave Kreskowiak17-Mar-08 7:15 
GeneralContinuous file monitoring problem Pin
arp_05915-Mar-08 4:09
arp_05915-Mar-08 4:09 
I 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()<br />
' following sections to read file line obtained from http://www.codeguru.com/forum/archive/index.php/t-315872.html<br />
Dim strFile As String<br />
Dim PortAddress As Integer<br />
'Dim iFile As Integer<br />
Dim strContent As String<br />
Dim strContent2 As String<br />
Dim strContent3 As String<br />
Dim strContent4 As String<br />
PortAddress = &H378<br />
'TO Do Add code here to put a filename with path in strFile<br />
Label1.Caption = "light is off"   'display status<br />
Label3.Caption = "fan is off"   'display status<br />
<br />
file1 = "c:\lighton.txt"<br />
file2 = "c:\lightoff.txt"<br />
file3 = "c:\fanon.txt"<br />
file4 = "c:\fanoff.txt"<br />
'iFile = FreeFile '1=lighton.txt 2=lightoff.txt 3=fanon.txt 4=fanoff.txt<br />
'restart:<br />
Do<br />
<br />
If (Len(Dir$(file1)) <> 0) Then     'lighton.txt file existance check<br />
    For j = 1 To 255<br />
    Close #j<br />
    Next j<br />
    Open "c:\lighton.txt" For Input As #1<br />
    'The following will read the first line from the file<br />
    Line Input #1, strContent ' read 1st line in the file<br />
    Close #1 ' close file<br />
        If (strContent = "light on") Then    'check validity of file<br />
            Label1.Caption = "light is on"   'display status<br />
            Value = Inp(PortAddress)<br />
            Value = Value Or &HF              'make lsbs high<br />
            Out PortAddress, Value           'output the value<br />
        End If<br />
    For i = 1 To 5<br />
        If (Len(Dir$(file2)) <> 0) Then     'lighton.txt file existance check<br />
            For j = 1 To 255<br />
            Close #j<br />
            Next j<br />
            Open "c:\lightoff.txt" For Input As #2<br />
                'The following will read the first line from the file<br />
            Line Input #2, strContent2 ' read 1st line in the file<br />
            Close #2 ' close file<br />
            If (strContent2 = "light off") Then    'check validity of file<br />
                Label1.Caption = "light is off"   'display status<br />
                Value = Inp(PortAddress)<br />
                Value = Value And &HF0             'make lsbs high<br />
                Out PortAddress, Value           'output the value<br />
                Kill "c:\lighton.txt"<br />
                Kill "c:\lightoff.txt"<br />
            End If<br />
        End If<br />
    Next i<br />
<br />
End If<br />
    <br />
    <br />
    <br />
' monitor for fan files<br />
<br />
If (Len(Dir$(file3)) <> 0) Then     'lighton.txt file existance check<br />
    For j = 1 To 255<br />
    Close #j<br />
    Next j<br />
    Open "c:\fanon.txt" For Input As #3<br />
    'The following will read the first line from the file<br />
    Line Input #3, strContent3 ' read 1st line in the file<br />
    Close #3 ' close file<br />
        If (strContent3 = "fan on") Then    'check validity of file<br />
            Label3.Caption = "fan is on"   'display status<br />
            Value = Inp(PortAddress)<br />
            Value = Value Or &HF0              'make lsbs high<br />
            Out PortAddress, Value          'output the value<br />
        End If<br />
    For i = 1 To 5<br />
        If (Len(Dir$(file4)) <> 0) Then     'lighton.txt file existance check<br />
            For j = 1 To 255<br />
            Close #j<br />
            Next j<br />
            Open "c:\fanoff.txt" For Input As #4<br />
                'The following will read the first line from the file<br />
            Line Input #4, strContent4 ' read 1st line in the file<br />
            Close #4 ' close file<br />
            If (strContent4 = "fan off") Then    'check validity of file<br />
                Label3.Caption = "fan is off"   'display status<br />
                Value = Inp(PortAddress)<br />
                Value = Value And &HF              'make lsbs high<br />
                Out PortAddress, Value           'output the value<br />
                Kill "c:\fanon.txt"<br />
                Kill "c:\fanoff.txt"<br />
            End If<br />
        End If<br />
    Next i<br />
<br />
End If<br />
<br />
<br />
<br />
   'Sleep 1000   'Implements a 1 second delay<br />
<br />
<br />
<br />
Loop Until ((Check1.Value = 0))<br />
<br />
'GoTo restart<br />
<br />
End Sub<br />
<br />
Private Sub Command2_Click()<br />
End<br />
End Sub<br />
<br />
<br />

GeneralRe: Continuous file monitoring problem Pin
Mycroft Holmes15-Mar-08 21:41
professionalMycroft Holmes15-Mar-08 21:41 
GeneralRe: Continuous file monitoring problem Pin
Dave Kreskowiak17-Mar-08 7:12
mveDave Kreskowiak17-Mar-08 7:12 
Generalhelp required with a stock system Pin
mickstar15-Mar-08 3:08
mickstar15-Mar-08 3:08 
GeneralRe: help required with a stock system Pin
Christian Graus16-Mar-08 11:15
protectorChristian Graus16-Mar-08 11:15 
GeneralDraw lines on picture in background Pin
patrik.michnac15-Mar-08 3:07
patrik.michnac15-Mar-08 3:07 
GeneralRe: Draw lines on picture in background Pin
Dave Kreskowiak17-Mar-08 6:58
mveDave Kreskowiak17-Mar-08 6:58 
QuestionHow to convert a value to a string with decimal point instead of comma Pin
DCAUB15-Mar-08 0:57
DCAUB15-Mar-08 0:57 
GeneralRe: How to convert a value to a string with decimal point instead of comma Pin
Colin Angus Mackay15-Mar-08 1:13
Colin Angus Mackay15-Mar-08 1:13 
GeneralRe: How to convert a value to a string with decimal point instead of comma Pin
DCAUB15-Mar-08 1:28
DCAUB15-Mar-08 1:28 
GeneralRe: How to convert a value to a string with decimal point instead of comma Pin
Colin Angus Mackay15-Mar-08 4:08
Colin Angus Mackay15-Mar-08 4:08 
QuestionHow to send a string over the internet to another pc Pin
softwarejaeger15-Mar-08 0:17
softwarejaeger15-Mar-08 0:17 
GeneralRe: How to send a string over the internet to another pc Pin
Dave Kreskowiak17-Mar-08 5:32
mveDave Kreskowiak17-Mar-08 5:32 
QuestionUsing System.windows.forms.datagrid Pin
shaeron14-Mar-08 22:36
shaeron14-Mar-08 22:36 
GeneralRe: Using System.windows.forms.datagrid Pin
Mycroft Holmes15-Mar-08 21:50
professionalMycroft Holmes15-Mar-08 21:50 
GeneralHowTo Refresh Data Bound Controls in VB.NET Compact Edition Pin
swdev.bali14-Mar-08 18:37
swdev.bali14-Mar-08 18:37 
QuestionConverting Excel VBA module code to VB 2005/VB.NET Pin
Graham Latto14-Mar-08 14:39
Graham Latto14-Mar-08 14:39 
GeneralRe: Converting Excel VBA module code to VB 2005/VB.NET Pin
Paul Conrad14-Mar-08 14:59
professionalPaul Conrad14-Mar-08 14:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.