First time playing with Shell...comments welcome
VB Code:
  1. ' Returns Gateway IP and more
  2.  
  3.     '
  4.     ' VbForums.com   User: SESSI4ML
  5.     '
  6. Sub Command1_Click()
  7.     Dim fname As String
  8.     '
  9.     fname = "c:\GateWay.txt"   ' Shell will not accept a long string. Max of ?
  10.     ' Must have spaces between command and options (flags)
  11.     '
  12.     Shell "c:\windows\system32\cmd.exe /c ipconfig/all > " + fname, vbMinimizedNoFocus
  13.     Wait 1      ' OS will process the next lines of code before it finishes the Shell request
  14.     Call LoadFile(fname)
  15.     Label1.Caption = fIpConFig("Gateway") + vbCrLf + fIpConFig("IP Address") + fIpConFig("Physical")
  16.    
  17. End Sub
  18. Private Sub LoadFile(strFile As String)
  19.     Dim fb As Integer: Dim strIn As String
  20.     If Len(strFile) = 0 Then Debug.Print "E1": Exit Sub
  21.     fb = FreeFile
  22.     If Dir(strFile) = "" Then Debug.Print "E2": Exit Sub    ' File was not created, Exit
  23.     Open strFile For Input As #fb
  24.        Do While EOF(fb) = False
  25.            Line Input #fb, strIn  ' Load line
  26.            Text1.Text = Text1.Text + strIn + vbCrLf     ' Load Text box
  27.     Loop
  28. End Sub
  29.  
  30. Function fIpConFig(strSearch As String) As String
  31.     ' Scan Text box
  32.     Dim int1 As Integer     ' First parameter
  33.     Dim int2 As Integer     ' Second parameter
  34.     Dim int3 As Integer     ' End of line
  35.     '
  36.     int1 = InStr(1, Text1.Text, strSearch)  ' Find Line
  37.     int2 = InStr(int1, Text1.Text, ":")     ' Find colon
  38.     int3 = InStr(int2, Text1.Text, vbCr)
  39.     fIpConFig = strSearch + " " + Mid(Text1.Text, int2 + 1, int3 - int2)
  40.  
  41. End Function
  42. '
  43.  
  44. Public Sub Wait(seconds As Integer)
  45. ' Thanks RhinoBull...[url]http://www.vbforums.com/showpost.php?p=2732926&postcount=5[/url]
  46. Dim dTimer As Double
  47.  
  48.     dTimer = Timer
  49.     Do While Timer < dTimer + seconds
  50.         DoEvents
  51.     Loop
  52.  
  53. End Sub