Open Network Share II

I have this working in its own project and its own form, I would like to add it to another form in another project.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21482820.html#14383652
CMILLERAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
What's your code look like?  What's not working?
If you added the code to a module - just add that module to the other project...
CMILLERAuthor Commented:
I tried that.

It is conflicting with something.

could it be this:

Private Sub Command1_Click()
Shell "cmd /c net send " & Text1.Text & " " & Text2.Text
End Sub
sirbountyCommented:
Nope - can you post your code?
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

CMILLERAuthor Commented:
'Dim TimerShutdown As Long
Dim FileName As String

Private Type PathVariable
    Drive As String
    Location As String
    FileName As String
End Type
Dim Exe As PathVariable

'********************************************************
'**************Declaring Functions for Ping**************
'********************************************************
    Const PING_SUCCESS = 1
    Const PING_FAIL = 0
    Private Declare Function GetRTTAndHopCount Lib "iphlpapi.dll" ( _
                ByVal lDestIPAddr As Long, _
                ByRef lHopCount As Long, _
                ByVal lMaxHops As Long, _
                ByRef lRTT As Long) As Long
    Private Declare Function inet_addr Lib "wsock32.dll" (ByVal cp As String) As Long
    Private Declare Function SleepEx Lib "kernel32" (ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long
'********************************************************
'********************************************************
'********************************************************

Private Sub CmbDrives_Change()
On Error GoTo handler
    Me.LstDirectory.Path = CmbDrives.Drive
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmbPattern_Click() 'Pattern Combo Box
On Error GoTo handler
    LstFiles.Pattern = CmbPattern.List(CmbPattern.ListIndex)
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmdClearHistory_Click() 'History Button
CmbRan.Clear
CmbModified.Clear
End Sub

Private Sub CmdEdit_Click() 'Edit Button
On Error GoTo handler
    Dim FileNameO As String
    Call GettingReady
    Me.LblFileRunning.Caption = Exe.FileName
    FileNameO = Exe.Drive & Exe.Location & "\" & Exe.FileName
    CmbModified.AddItem FileNameO
    Shell "notepad " & FileNameO, vbNormalFocus
    CmbModified.ListIndex = 0
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmdExecute_Click()  'Button Execute
On Error GoTo handler
    Me.LblFileRunning.Caption = Exe.FileName
    Call Shelling
    CmbRan.ListIndex = 0
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmdExit_Click() 'Exit Button
X = MsgBox("Are you sure you want to do this?!", vbYesNo, "Bye Bye")
If X = 6 Then
    End
Else
    MsgBox "This was a wise desicion! I'm proud of you", vbOKOnly, "Thank you"
End If
End Sub


Private Sub CmdHelp_Click() 'Help Button
On Error GoTo handler
    Shell "notepad " & App.Path & "\help.txt", vbMaximizedFocus
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmdPing_Click() 'Button Ping
Dim IPAddress As Variant, nHop As Long, nTime As Long
Me.MousePointer = vbHourglass
For i = 0 To 3
    If TxtIP(i).Text = "" Then
        MsgBox "Please input numeric value", vbOKOnly, "Error"
        Me.MousePointer = vbDefault
        Exit Sub
    End If
Next i
IPAddress = TxtIP(0) & "." & TxtIP(1) & "." & TxtIP(2) & "." & TxtIP(3)
nHop = 0
nTime = 10000

If FastPing(IPAddress, nHop, nTime) = True Then
    TxtResult = "TRUE"
Else
    TxtResult = "FALSE"
End If
Me.TxtHopCount = nHop
Me.TxtTime = nTime
Me.MousePointer = vbDefault
End Sub

Private Sub Command1_Click()
Shell "cmd /c net send " & Text1.Text & " " & Text2.Text
End Sub



Private Sub Command2_Click()
ShellEx Text1.Text, , , , , Me.hWnd
End Sub






Private Sub Form_Load() 'Loading From
On Error GoTo handler
'    TimerShutdown = 0 For Demo Purpose only
    CmbPattern.ListIndex = 0
    LstFiles.Pattern = CmbPattern.List(CmbPattern.ListIndex)
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstDirectory_Change()
On Error GoTo handler
    Me.LstFiles.Path = Me.LstDirectory.Path
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstFiles_DblClick()
On Error GoTo handler
    Me.LstSelected.AddItem LstFiles.List(LstFiles.ListIndex)
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstSelected_Click()
        If LstSelected.ListIndex > -1 Then
            Me.CmdEdit.Enabled = True
            Me.CmdExecute.Enabled = True
        Else
            Me.CmdEdit.Enabled = False
            Me.CmdExecute.Enabled = False
        End If
End Sub

Private Sub LstSelected_DblClick()
On Error GoTo handler
    Call Shelling
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

'This subroutine is the program core, it run the CMD.exe to execute the batch file
Private Sub Shelling()
On Error GoTo handler
    Call GettingReady
    FileName = Exe.Drive & Exe.Location & "\" & Exe.FileName
    CmbRan.AddItem FileName         'Add file to history combobox
    Me.LblFileRunning.Caption = Exe.FileName    'Type the file name in the yellow label
    Shell FileName, vbMaximizedFocus    'Run CMD.EXE
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstSelected_KeyPress(KeyAscii As Integer)   'Final Selected List
On Error GoTo handler
'This code refer to delete button when you click delete it removes the file
    Select Case KeyAscii
    Case 8
        Me.LstSelected.RemoveItem Me.LstSelected.ListIndex
    End Select
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstSelected_LostFocus()
If LstSelected.ListIndex = -1 Then
    Me.CmdEdit.Enabled = False
    Me.CmdExecute.Enabled = False
End If
End Sub

Private Sub LstSelected_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo handler
'same like deleting but it uses the right mouse button.
    Select Case Button
    Case 2
        If Me.LstSelected.ListCount = 0 Or Me.LstSelected.ListIndex = -1 Then
        Else
            Me.LstSelected.RemoveItem Me.LstSelected.ListIndex
        End If
   
        If LstSelected.ListIndex > -1 Then
            Me.CmdEdit.Enabled = True
            Me.CmdExecute.Enabled = True
        Else
            Me.CmdEdit.Enabled = False
            Me.CmdExecute.Enabled = False
        End If
    End Select
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

'********************************************************
'**************Supplementary functions*******************
'********************************************************

Private Sub GettingReady()
'Gathering the file to be run location
    Exe.Drive = GetDrive(CmbDrives.Drive)
    Exe.Location = GetPath(Me.LstDirectory.Path)
    Exe.FileName = LstSelected.List(LstSelected.ListIndex)
End Sub

Private Function GetDrive(Drive As String) As String
On Error GoTo handler
    GetDrive = Left(Drive, 2) & "\"
Exit Function
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Function

Private Function GetPath(Location As String) As String
On Error GoTo handler
    GetPath = Right(Location, Len(Location) - 3)
Exit Function
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Function

'********************************************************
'**************Demo Puropose Timer **********************
'********************************************************
'Private Sub TimerSetting_Timer()
'Me.LblTimeLeft.Caption = (60 - TimerShutdown) & " sec"
'If TimerShutdown > 60 Then
'    MsgBox "Thank you for using the DEMO version, please let me know if you like it." & vbCrLf & _
'    " you can mail me at m13badry@hotmail.com ", vbOKOnly, "Demo Version"
'    End
'End If
'TimerShutdown = TimerShutdown + 1
'End Sub


'********************************************************
'**************PING Functions ***************************
'********************************************************

' ----------------------------------------------------------------
' IP address may be a Long (Network Byte Order) or Dot4 IP.
' nHops is MaxHops Input (0 = Automatic) and Ping Hop-Count on return
' nRoundTripTime is aprox Round Trip Ping Time in milliseconds.
' Returns either True or False for Ping Successful or not.
' ----------------------------------------------------------------
Public Function FastPing(vIPaddr As Variant, nHops As Long, nRoundTripTime As Long) As Boolean
  Dim nIP As Long
  Dim nLimit As Long
    If VarType(vIPaddr) = vbString Then
        nIP = inet_addr(vIPaddr)                'Dot4 String i.e. 127.0.0.1 (LocalHost)
    ElseIf VarType(vIPaddr) = vbLong Then
        nIP = vIPaddr                           'Long - Network Byte Order
    Else
        nHops = 0
        nRoundTripTime = (-1)
        Exit Function
    End If
    nLimit = nHops
    If nLimit < 1 Then nLimit = 50          'Maximum of 50 Hops
    nHops = 0                               'Return number of Hops
    nRoundTripTime = 0                      'Return Round Trip Time in milliseconds
    FastPing = (GetRTTAndHopCount(nIP, nHops, nLimit, nRoundTripTime) = PING_SUCCESS)
End Function




'When you click '.' dot in the IP Address boxes it'll shift to the next box
Private Sub TxtIP_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii <> 8 Then
        Select Case KeyAscii
            Case 46
                If Index < 3 Then
                    TxtIP(Index + 1).SetFocus
                    KeyAscii = 0
                End If
        End Select
    If KeyAscii < 48 Or KeyAscii > 59 Then
        KeyAscii = 0
    End If
End If
End Sub



sirbountyCommented:
And it errors at
ShellEx Text1.Text, , , , , Me.hWnd
??

Is the ShellEx declared as public in your module?
CMILLERAuthor Commented:
I just copied and pasted from your post
sirbountyCommented:
What's the error message?  What's in Text1.Text?
CMILLERAuthor Commented:
the error is that when I type in the text box:

\\computername\c$

it takes me to C:\Program Files\Microsoft Visual Studio\VB98

and if I type in " cmd " in the box it takes me to the same place.

If I remove the net send frame it works fine
sirbountyCommented:
Odd - Command1 calls the cmd /c net send routine
Command2 is calling the shellex, correct?

Place a breakpoint on Command2_Click and step through it and determine what is in Text1.Text before you commit it...
CMILLERAuthor Commented:
Its odd,

If I have the net send only, the net send works

If I have the net send and the command box, neither works

If I have the command box, it works

If I have the command box and net send , neither works
CMILLERAuthor Commented:
Sorry, I dont know how to place a breakpoint, how do I do that
sirbountyCommented:
Can you clarify what you mean by having the net send and the command box - which command box?

Ultimately, you want to use the same text box for the \\computername\c$ and for the net send message?
sirbountyCommented:
Highlight the Command2_CLick sub and hit F9 - it should turn an ugly color of brown...
CMILLERAuthor Commented:
the network share box

ShellEx Text1.Text,,,,,Me.hWnd
CMILLERAuthor Commented:
no not the same box
CMILLERAuthor Commented:
it is two separate frames
sirbountyCommented:
So, you have the one form and the one module?
Can you open up your frm file with notepad and paste that here? (not in VB)
This will give me an idea of what your program looks like and what controls you're using...if you don't mind..
CMILLERAuthor Commented:
So, you have the one form and the one module?

<Yes

and within the form I have some frames

**********************************************************

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Begin VB.Form FrmCLIGUI
   BorderStyle     =   1  'Fixed Single
   Caption         =   "CLI-GUI 1.0"
   ClientHeight    =   9675
   ClientLeft      =   1635
   ClientTop       =   390
   ClientWidth     =   10785
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   9675
   ScaleWidth      =   10785
   Begin VB.Frame Frame2
      Caption         =   "Frame2"
      Height          =   3135
      Left            =   7440
      TabIndex        =   44
      Top             =   4200
      Width           =   3135
      Begin VB.CommandButton Command2
         Caption         =   "Command2"
         Height          =   735
         Left            =   960
         TabIndex        =   46
         Top             =   1560
         Width           =   1335
      End
      Begin VB.TextBox Text3
         Height          =   495
         Left            =   240
         TabIndex        =   45
         Text            =   "Text3"
         Top             =   480
         Width           =   2655
      End
   End
   Begin VB.Frame Frame1
      Caption         =   "Frame1"
      Height          =   3255
      Left            =   7320
      TabIndex        =   40
      Top             =   480
      Width           =   3135
      Begin VB.CommandButton Command1
         Caption         =   "Command1"
         Height          =   495
         Left            =   1080
         TabIndex        =   43
         Top             =   2400
         Width           =   1215
      End
      Begin VB.TextBox Text2
         Height          =   855
         Left            =   360
         TabIndex        =   42
         Text            =   "Text2"
         Top             =   1320
         Width           =   2295
      End
      Begin VB.TextBox Text1
         Height          =   615
         Left            =   360
         TabIndex        =   41
         Text            =   "Text1"
         Top             =   360
         Width           =   2295
      End
   End
   Begin VB.Frame Frames
      Caption         =   "Command-Line PING"
      Height          =   1845
      Index           =   2
      Left            =   30
      TabIndex        =   22
      Top             =   7440
      Width           =   6975
      Begin VB.TextBox TxtDescription
         Appearance      =   0  'Flat
         BeginProperty Font
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000C0&
         Height          =   1305
         Left            =   4260
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   39
         Text            =   "Form1.frx":0442
         Top             =   300
         Width           =   2565
      End
      Begin VB.CommandButton CmdPing
         Caption         =   "PING"
         Height          =   255
         Left            =   2550
         TabIndex        =   38
         Top             =   1380
         Width           =   885
      End
      Begin VB.TextBox TxtResult
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         Height          =   285
         Left            =   1260
         Locked          =   -1  'True
         TabIndex        =   37
         Top             =   1350
         Width           =   1155
      End
      Begin VB.TextBox TxtTime
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         Height          =   285
         Left            =   1260
         TabIndex        =   34
         Text            =   "60000"
         Top             =   990
         Width           =   1155
      End
      Begin VB.TextBox TxtHopCount
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         Height          =   285
         Left            =   1260
         TabIndex        =   32
         Text            =   "0"
         Top             =   660
         Width           =   525
      End
      Begin VB.TextBox TxtIP
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         Height          =   285
         Index           =   3
         Left            =   3210
         TabIndex        =   27
         Top             =   330
         Width           =   555
      End
      Begin VB.TextBox TxtIP
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         Height          =   285
         Index           =   2
         Left            =   2580
         TabIndex        =   26
         Top             =   330
         Width           =   525
      End
      Begin VB.TextBox TxtIP
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         Height          =   285
         Index           =   1
         Left            =   1920
         TabIndex        =   25
         Top             =   330
         Width           =   525
      End
      Begin VB.TextBox TxtIP
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         Height          =   285
         Index           =   0
         Left            =   1260
         TabIndex        =   24
         Top             =   330
         Width           =   525
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "Ping Result:"
         Height          =   195
         Index           =   9
         Left            =   270
         TabIndex        =   36
         Top             =   1380
         Width           =   855
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "in Milliseconds"
         Height          =   195
         Index           =   8
         Left            =   2520
         TabIndex        =   35
         Top             =   1020
         Width           =   1020
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "Time:"
         Height          =   195
         Index           =   7
         Left            =   270
         TabIndex        =   33
         Top             =   1020
         Width           =   390
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "Hop Count:"
         Height          =   195
         Index           =   6
         Left            =   270
         TabIndex        =   31
         Top             =   690
         Width           =   810
      End
      Begin VB.Label Label1
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "."
         BeginProperty Font
            Name            =   "Tahoma"
            Size            =   12
            Charset         =   178
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Index           =   2
         Left            =   3135
         TabIndex        =   30
         Top             =   300
         Width           =   75
      End
      Begin VB.Label Label1
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "."
         BeginProperty Font
            Name            =   "Tahoma"
            Size            =   12
            Charset         =   178
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Index           =   1
         Left            =   2475
         TabIndex        =   29
         Top             =   300
         Width           =   75
      End
      Begin VB.Label Label1
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "."
         BeginProperty Font
            Name            =   "Tahoma"
            Size            =   12
            Charset         =   178
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   345
         Index           =   0
         Left            =   1815
         TabIndex        =   28
         Top             =   300
         Width           =   75
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "IP Adress:"
         Height          =   195
         Index           =   5
         Left            =   270
         TabIndex        =   23
         Top             =   360
         Width           =   720
      End
   End
   Begin VB.Frame Frames
      Caption         =   "History:"
      Height          =   1515
      Index           =   1
      Left            =   0
      TabIndex        =   15
      Top             =   5880
      Width           =   7035
      Begin VB.CommandButton CmdClearHistory
         Caption         =   "Clear History"
         Height          =   255
         Left            =   5670
         TabIndex        =   21
         Top             =   1200
         Width           =   1155
      End
      Begin VB.ComboBox CmbModified
         Height          =   315
         Left            =   1500
         Style           =   2  'Dropdown List
         TabIndex        =   19
         Top             =   690
         Width           =   5355
      End
      Begin VB.ComboBox CmbRan
         Height          =   315
         Left            =   1500
         Style           =   2  'Dropdown List
         TabIndex        =   17
         Top             =   270
         Width           =   5355
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "File you modified:"
         Height          =   195
         Index           =   4
         Left            =   210
         TabIndex        =   18
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "File you ran:"
         Height          =   195
         Index           =   3
         Left            =   240
         TabIndex        =   16
         Top             =   300
         Width           =   855
      End
   End
   Begin MSComctlLib.StatusBar StatusBar1
      Align           =   2  'Align Bottom
      Height          =   345
      Left            =   0
      TabIndex        =   13
      Top             =   9330
      Width           =   10785
      _ExtentX        =   19024
      _ExtentY        =   609
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
         NumPanels       =   4
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
            Style           =   6
            TextSave        =   "7/7/2005"
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
            Style           =   5
            TextSave        =   "11:04 AM"
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
            Style           =   1
            Enabled         =   0   'False
            TextSave        =   "CAPS"
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628}
            Style           =   2
            TextSave        =   "NUM"
         EndProperty
      EndProperty
   End
   Begin VB.Timer TimerSetting
      Interval        =   1000
      Left            =   3000
      Top             =   2730
   End
   Begin VB.Frame Frames
      Caption         =   "Command-Line GUI"
      Height          =   5835
      Index           =   0
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   7035
      Begin VB.CommandButton CmdHelp
         Caption         =   "Help me ?"
         Height          =   345
         Left            =   4230
         TabIndex        =   20
         Top             =   120
         Width           =   2745
      End
      Begin VB.CommandButton CmdExit
         Caption         =   "Exit"
         Height          =   285
         Left            =   5820
         TabIndex        =   14
         Top             =   5055
         Width           =   975
      End
      Begin VB.ComboBox CmbPattern
         Height          =   315
         ItemData        =   "Form1.frx":0514
         Left            =   5070
         List            =   "Form1.frx":0524
         Style           =   2  'Dropdown List
         TabIndex        =   9
         Top             =   510
         Width           =   1725
      End
      Begin VB.CommandButton CmdExecute
         Caption         =   "Execute"
         Enabled         =   0   'False
         Height          =   285
         Left            =   3870
         TabIndex        =   6
         Top             =   5055
         Width           =   975
      End
      Begin VB.CommandButton CmdEdit
         Caption         =   "Edit"
         Enabled         =   0   'False
         Height          =   285
         Left            =   4845
         TabIndex        =   5
         Top             =   5055
         Width           =   975
      End
      Begin VB.ListBox LstSelected
         Height          =   1035
         Left            =   210
         TabIndex        =   4
         Top             =   3810
         Width           =   6585
      End
      Begin VB.FileListBox LstFiles
         Height          =   3015
         Left            =   4050
         Pattern         =   "*.CMD"
         System          =   -1  'True
         TabIndex        =   3
         Top             =   840
         Width           =   2745
      End
      Begin VB.DirListBox LstDirectory
         Height          =   3015
         Left            =   210
         TabIndex        =   2
         Top             =   840
         Width           =   3825
      End
      Begin VB.DriveListBox CmbDrives
         Height          =   315
         Left            =   210
         TabIndex        =   1
         Top             =   480
         Width           =   3825
      End
      Begin VB.Label LblTimeLeft
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         BorderStyle     =   1  'Fixed Single
         BeginProperty Font
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   178
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   2010
         TabIndex        =   12
         Top             =   5040
         Visible         =   0   'False
         Width           =   1725
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "Time Left:"
         Height          =   195
         Index           =   2
         Left            =   1260
         TabIndex        =   11
         Top             =   5025
         Visible         =   0   'False
         Width           =   705
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "File Types:"
         Height          =   195
         Index           =   1
         Left            =   4230
         TabIndex        =   10
         Top             =   570
         Width           =   765
      End
      Begin VB.Label LblFileRunning
         Appearance      =   0  'Flat
         BackColor       =   &H00C0FFFF&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   315
         Left            =   240
         TabIndex        =   8
         Top             =   5370
         Width           =   6585
      End
      Begin VB.Label LblDescriptions
         AutoSize        =   -1  'True
         Caption         =   "Running File:"
         Height          =   195
         Index           =   0
         Left            =   270
         TabIndex        =   7
         Top             =   5130
         Width           =   930
      End
   End
End
Attribute VB_Name = "FrmCLIGUI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'**************************************************************************
'*****This software is coded by Mohamed Adel El-Badry**********************
'*****You're authorized to redistribute, modify this code******************
'*****in any way you like, there is no obligations on you******************
'*****I'll appreciated if you just recommended me for further**************
'*****projects.************************************************************
'*****For any support please contact me at m13badry@hotmail.com************
'**************************************************************************
'**************************************************************************
'**************************************************************************


'Dim TimerShutdown As Long
Dim FileName As String

Private Type PathVariable
    Drive As String
    Location As String
    FileName As String
End Type
Dim Exe As PathVariable

'********************************************************
'**************Declaring Functions for Ping**************
'********************************************************
    Const PING_SUCCESS = 1
    Const PING_FAIL = 0
    Private Declare Function GetRTTAndHopCount Lib "iphlpapi.dll" ( _
                ByVal lDestIPAddr As Long, _
                ByRef lHopCount As Long, _
                ByVal lMaxHops As Long, _
                ByRef lRTT As Long) As Long
    Private Declare Function inet_addr Lib "wsock32.dll" (ByVal cp As String) As Long
    Private Declare Function SleepEx Lib "kernel32" (ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long
'********************************************************
'********************************************************
'********************************************************

Private Sub CmbDrives_Change()
On Error GoTo handler
    Me.LstDirectory.Path = CmbDrives.Drive
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmbPattern_Click() 'Pattern Combo Box
On Error GoTo handler
    LstFiles.Pattern = CmbPattern.List(CmbPattern.ListIndex)
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmdClearHistory_Click() 'History Button
CmbRan.Clear
CmbModified.Clear
End Sub

Private Sub CmdEdit_Click() 'Edit Button
On Error GoTo handler
    Dim FileNameO As String
    Call GettingReady
    Me.LblFileRunning.Caption = Exe.FileName
    FileNameO = Exe.Drive & Exe.Location & "\" & Exe.FileName
    CmbModified.AddItem FileNameO
    Shell "notepad " & FileNameO, vbNormalFocus
    CmbModified.ListIndex = 0
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmdExecute_Click()  'Button Execute
On Error GoTo handler
    Me.LblFileRunning.Caption = Exe.FileName
    Call Shelling
    CmbRan.ListIndex = 0
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmdExit_Click() 'Exit Button
x = MsgBox("Are you sure you want to do this?!", vbYesNo, "Bye Bye")
If x = 6 Then
    End
Else
    MsgBox "This was a wise desicion! I'm proud of you", vbOKOnly, "Thank you"
End If
End Sub


Private Sub CmdHelp_Click() 'Help Button
On Error GoTo handler
    Shell "notepad " & App.Path & "\help.txt", vbMaximizedFocus
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub CmdPing_Click() 'Button Ping
Dim IPAddress As Variant, nHop As Long, nTime As Long
Me.MousePointer = vbHourglass
For i = 0 To 3
    If TxtIP(i).Text = "" Then
        MsgBox "Please input numeric value", vbOKOnly, "Error"
        Me.MousePointer = vbDefault
        Exit Sub
    End If
Next i
IPAddress = TxtIP(0) & "." & TxtIP(1) & "." & TxtIP(2) & "." & TxtIP(3)
nHop = 0
nTime = 10000

If FastPing(IPAddress, nHop, nTime) = True Then
    TxtResult = "TRUE"
Else
    TxtResult = "FALSE"
End If
Me.TxtHopCount = nHop
Me.TxtTime = nTime
Me.MousePointer = vbDefault
End Sub

Private Sub Command1_Click()
Shell "cmd /c net send " & Text1.Text & " " & Text2.Text
 Text1.Text = ""
 Text2.Text = ""
End Sub



Private Sub Command2_Click()
ShellEx Text1.Text, , , , , Me.hWnd
End Sub

Private Sub Form_Load() 'Loading From
On Error GoTo handler
'    TimerShutdown = 0 For Demo Purpose only
    CmbPattern.ListIndex = 0
    LstFiles.Pattern = CmbPattern.List(CmbPattern.ListIndex)
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstDirectory_Change()
On Error GoTo handler
    Me.LstFiles.Path = Me.LstDirectory.Path
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstFiles_DblClick()
On Error GoTo handler
    Me.LstSelected.AddItem LstFiles.List(LstFiles.ListIndex)
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstSelected_Click()
        If LstSelected.ListIndex > -1 Then
            Me.CmdEdit.Enabled = True
            Me.CmdExecute.Enabled = True
        Else
            Me.CmdEdit.Enabled = False
            Me.CmdExecute.Enabled = False
        End If
End Sub

Private Sub LstSelected_DblClick()
On Error GoTo handler
    Call Shelling
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

'This subroutine is the program core, it run the CMD.exe to execute the batch file
Private Sub Shelling()
On Error GoTo handler
    Call GettingReady
    FileName = Exe.Drive & Exe.Location & "\" & Exe.FileName
    CmbRan.AddItem FileName         'Add file to history combobox
    Me.LblFileRunning.Caption = Exe.FileName    'Type the file name in the yellow label
    Shell FileName, vbMaximizedFocus    'Run CMD.EXE
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstSelected_KeyPress(KeyAscii As Integer)   'Final Selected List
On Error GoTo handler
'This code refer to delete button when you click delete it removes the file
    Select Case KeyAscii
    Case 8
        Me.LstSelected.RemoveItem Me.LstSelected.ListIndex
    End Select
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

Private Sub LstSelected_LostFocus()
If LstSelected.ListIndex = -1 Then
    Me.CmdEdit.Enabled = False
    Me.CmdExecute.Enabled = False
End If
End Sub

Private Sub LstSelected_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
On Error GoTo handler
'same like deleting but it uses the right mouse button.
    Select Case Button
    Case 2
        If Me.LstSelected.ListCount = 0 Or Me.LstSelected.ListIndex = -1 Then
        Else
            Me.LstSelected.RemoveItem Me.LstSelected.ListIndex
        End If
   
        If LstSelected.ListIndex > -1 Then
            Me.CmdEdit.Enabled = True
            Me.CmdExecute.Enabled = True
        Else
            Me.CmdEdit.Enabled = False
            Me.CmdExecute.Enabled = False
        End If
    End Select
Exit Sub
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Sub

'********************************************************
'**************Supplementary functions*******************
'********************************************************

Private Sub GettingReady()
'Gathering the file to be run location
    Exe.Drive = GetDrive(CmbDrives.Drive)
    Exe.Location = GetPath(Me.LstDirectory.Path)
    Exe.FileName = LstSelected.List(LstSelected.ListIndex)
End Sub

Private Function GetDrive(Drive As String) As String
On Error GoTo handler
    GetDrive = Left(Drive, 2) & "\"
Exit Function
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Function

Private Function GetPath(Location As String) As String
On Error GoTo handler
    GetPath = Right(Location, Len(Location) - 3)
Exit Function
handler:
    MsgBox Err.Description, vbOKOnly, "Error in Demo Version"
End Function

'********************************************************
'**************Demo Puropose Timer **********************
'********************************************************
'Private Sub TimerSetting_Timer()
'Me.LblTimeLeft.Caption = (60 - TimerShutdown) & " sec"
'If TimerShutdown > 60 Then
'    MsgBox "Thank you for using the DEMO version, please let me know if you like it." & vbCrLf & _
'    " you can mail me at m13badry@hotmail.com ", vbOKOnly, "Demo Version"
'    End
'End If
'TimerShutdown = TimerShutdown + 1
'End Sub


'********************************************************
'**************PING Functions ***************************
'********************************************************

' ----------------------------------------------------------------
' IP address may be a Long (Network Byte Order) or Dot4 IP.
' nHops is MaxHops Input (0 = Automatic) and Ping Hop-Count on return
' nRoundTripTime is aprox Round Trip Ping Time in milliseconds.
' Returns either True or False for Ping Successful or not.
' ----------------------------------------------------------------
Public Function FastPing(vIPaddr As Variant, nHops As Long, nRoundTripTime As Long) As Boolean
  Dim nIP As Long
  Dim nLimit As Long
    If VarType(vIPaddr) = vbString Then
        nIP = inet_addr(vIPaddr)                'Dot4 String i.e. 127.0.0.1 (LocalHost)
    ElseIf VarType(vIPaddr) = vbLong Then
        nIP = vIPaddr                           'Long - Network Byte Order
    Else
        nHops = 0
        nRoundTripTime = (-1)
        Exit Function
    End If
    nLimit = nHops
    If nLimit < 1 Then nLimit = 50          'Maximum of 50 Hops
    nHops = 0                               'Return number of Hops
    nRoundTripTime = 0                      'Return Round Trip Time in milliseconds
    FastPing = (GetRTTAndHopCount(nIP, nHops, nLimit, nRoundTripTime) = PING_SUCCESS)
End Function

'When you click '.' dot in the IP Address boxes it'll shift to the next box
Private Sub TxtIP_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii <> 8 Then
        Select Case KeyAscii
            Case 46
                If Index < 3 Then
                    TxtIP(Index + 1).SetFocus
                    KeyAscii = 0
                End If
        End Select
    If KeyAscii < 48 Or KeyAscii > 59 Then
        KeyAscii = 0
    End If
End If
End Sub
sirbountyCommented:
Ah - I see the problem...make this change to Command2_Click:

ShellEx Text3.Text, , , , , Me.hWnd

(Text3, not Text1)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CMILLERAuthor Commented:
I had thought of that to, and changed it once but, I guess I didnt change it to the correct number,
I think I used " text2 "

Let me try that, BRB
CMILLERAuthor Commented:
Yep, That worked

Thanks

sirbountyCommented:
Great!
Good luck with your project.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.