Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 9th, 2006, 11:11 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to put result of shell function into variable

Hi all .I have difficulty outputing the value of shell function into massagebox by using regoutput variable. Currently the shell function writes the output to .reg file but i want i want to output it to massage box but it never works!! The output value is list of registery information which are half a page char mostly .

i tried diffrent datatyes and i got diffrent 4 digit integer each time!!
Below is the code and it writes the correct registery values into .reg file but i want to display it in massagebox and non of the data types works!!

Is there any way to display the registeiory information directly into massage box instead of writing it to reg file.?
since i evantually want to get rid of wirting to file process .
I be happy if some expert help me.Thanks



Code:
Private Sub Reg(Path As String)

Dim regoutput

task_id  = shell("Regedit.exe /e " & Chr(34) & Path & Chr(34) & " " & Chr(34) & _
"HKEY_CURRENT_USER" & "\" & "Software\me\" & Chr(34))
'The Char For " is Chr(34)

MsgBox "shell function output: "+regoutput
End Sub

Private Sub Save_Click()


On Error Resume Next

CD.DialogTitle = "Save Registry Backup File As..."
CD.InitDir = App.Path
CD.Flags = &H4
CD.Filter = "Registry File Format (*.reg)|*.reg"
CD.ShowSave

If InStr(CD.FileName, ".reg") Then

Call Reg(CD.FileName)

DoEvents

Text1.Text = CD.FileName


End If

End Sub
 
Old April 20th, 2006, 11:42 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Method,

In VB you can add a literal " to a string with 2 quotes in a row. So
Code:
    task_id = shell("Regedit.exe /e " & Chr(34) & Path & Chr(34) & " " & Chr(34) & _
                    "HKEY_CURRENT_USER" & "\" & "Software\me\" & Chr(34))
                    could be
Code:
    task_id = shell("Regedit.exe /e """ & Path & """ ""HKEY_CURRENT_USER\Software\me\""")


Inasmuch as your code succeeds in creating a file, why don't you just open that file from VB, and read its contents into a message box? I recommend using the FileSystemObject to do this—I just love its simplicity.

(By the way: your code is not creating the file, RegEdit.exe is.)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of VB.NET's Shell function in C# jude_wong C# 8 December 16th, 2005 07:49 PM
put a space in between each variable crmpicco Javascript How-To 1 June 7th, 2005 11:58 AM
Using the Shell Function RAPSR59 Access 1 April 13th, 2005 07:14 AM
shell function problem bml Excel VBA 1 February 12th, 2005 05:42 PM
Shell Function Question SerranoG Access VBA 4 November 12th, 2003 07:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.