CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 1999
    Location
    France
    Posts
    29

    How get the prompt information?

    Exemple:
    You have a environmental variable called "MYVAR" and its value is "c:\MyFolder\VB"
    if you enter "set myvar" at the dos prompt, the windows displays "MYVAR=c:\MyFolder\VB"

    HOW can I get the line "MYVAR=c:\MyFolder\VB" with vb code??
    This is an example, I know that the Environ function return environmental variables.

    But generally, I want to get the prompt returned information (scanf in C...)

    Fzz


  2. #2
    Join Date
    Sep 1999
    Posts
    202

    Re: How get the prompt information?

    redirect result to a textfile:

    option Explicit

    private Sub Form_Click()
    Dim sLine as string, Msg as string
    ' execute command
    Shell "command.com /c " & "set > c:\info.txt"
    'Shell "command.com /c " & "dir/w > c:\info.txt"

    DoEvents

    ' read file
    Open "c:\info.txt" for input as #1
    Do While Not EOF(1)
    Line input #1, sLine
    Msg = Msg & sLine & vbCrLf
    Loop
    Close #1

    MsgBox Msg ' show result
    End Sub



    Note:
    you can add pause after Shell, or you can use some advanced code to ShellAndWait


  3. #3
    Guest

    Re: How get the prompt information?

    You can use this function;

    Environ({envstring | number})

    as in

    myVar = environ("MYVAR")



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

Featured