| Variables from one script to another |
|
 |
Index ‹ Visual Studio ‹ VB Scripts
|
- Previous
- 1
- Visual Basic [VB] >> enable tabcontrolon my form I have a checkbox and a tab control when the checkbox is true I
wish to enable the controls on a single page of the tab control, is this
possible or do I need to enable each control on the tab control page.
if you could supply and example of code it would be much appreciated
thanks phil
- 2
- VB Scripts >> How do I output the Text between 2 strings to a text file?HELP!I am trying to output the text between two strings , i giot to wite a
routine somthing as shown,but the output text file is BLANK!What am I
doing wron?I am new to VB script...Please Help!
Ajay
startstring = "ASSOCIATION TOTALS BY ACCOUNT TYPE"
endstring = "TOTAL""
sData = ReadFile("C:\Documents and Settings\Owner.AJAYGARG\My_
Documents\ASSOCIATION TOTALS BY ACCOUNT TYPE.doc")
startposition = InStr(sData, startstring)
sData = Left(sData, startposition)
endposition = InStr(sData, endstring) + Len(endstring) - 1
sData = Left(sData, endposition)
WScript.echo sData
Function ReadFile(FilePath)
'Given the path to a file, will return entire contents
' works with either ANSI or Unicode
Dim FSO, CurrentFile
Const ForReading = 1, TristateUseDefault = -2, _
DoNotCreateFile = False
Set FSO = createobject("Scripting.FileSystemObject")
If FSO.FileExists(FilePath) Then
If FSO.GetFile(FilePath).Size>0 Then
Set CurrentFile = FSO.OpenTextFile(FilePath, ForReading, _
False, TristateUseDefault)
If CurrentFile.AtEndOfStream <> True Then
ReadFile = CurrentFile.ReadAll
WriteFile "C:\Documents and Settings\Owner.AJAYGARG\My
Documents\ASSOCIATION TOTALS BY ACCOUNT TYPEf.doc", outData
: CurrentFile.Close
End If
End If
End If
End Function
Sub WriteFile(FILEPATH, sData)
'writes sData to FilePath
With CreateObject("Scripting.FileSystemObject")._
OpenTextFile(FilePath, 2, True)
.Write sData: .Close
End With
End Sub
- 3
- MFC >> Message which is called everytime a CFormView is createdHallo,
I have a program with a CSplitterWnd which divides 2 CFormViews.
See link: http://wwwstud.fh-zwickau.de/~pafe/geb/1.jpg
When I start the program the ListBox (CListView) on the right side
gets filled in the method OnInitialUpdate().
When I navigate through the tree then the views on the right side are
replaced.
When I come back to the element, that displays the form with the
List-Box, my ListBox is not filled with the data I provide in
OnInitialUpdate.
See link: http://wwwstud.fh-zwickau.de/~pafe/geb/2.jpg
Now my question is:
Where do I have to put the code (what message do I have to catch) to
get the ListBox filled everytime I select the corresponding
tree-element.
Thx 4 ur help
Pedde
- 4
- Visual Basic [VB] >> Mismatch between sample code and wizard skeleton/starting point ?I have a question regarding code examples in the msdn cd.
For example I will refer to the help page titled
"Using TCP Services"
As we can see, the code below is supposed to be for
a console application. My question is this: if I create
a console application with the wizard, I get a Main
sub which is inside Module1, whereas here, in the
sample, main is in a class called TcpTimeClient.
I.e. there is some implicit understanding here that one
would know how to insert this sample into the basic
template that the Console Application wizard gives
us. Is this mentioned anywhere ?
[Visual Basic]
Imports System
Imports System.Net.Sockets
Imports System.Text
Public Class TcpTimeClient
Private const portNum As Integer = 13
Private const hostName As String = "host.contoso.com"
' Entry point that delegates to C-style main Private Function.
Public Overloads Shared Sub Main()
System.Environment.ExitCode = _
Main(System.Environment.GetCommandLineArgs())
End Sub
Overloads Public Shared Function Main(args() As [String]) As Integer
Try
Dim client As New TcpClient(hostName, portNum)
Dim ns As NetworkStream = client.GetStream()
Dim bytes(1024) As Byte
Dim bytesRead As Integer = ns.Read(bytes, 0, bytes.Length)
Console.WriteLine(Encoding.ASCII.GetString(bytes, 0, bytesRead))
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
client.Close()
Return 0
End Function 'Main
End Class 'TcpTimeClient
- 5
- Visual Basic [VB] >> Unable to access c# code from VB.NET in the same solutionThis is a little puzzling,
I have a solution (SolutionA)
and have about 14 Projects in it that are VB.NET
I have to use some code which is C# and thought I could just add a reference
and use that to call the methods in the file. Seeems not to be the case, I
have added the reference but the project's classes or project reference does
not show up on the autolist that imports gives.
essentially the solution doesn't see the csharp class.
any ideas?
- 6
- Visual Basic >> Print preview and print for picture controlI have a form that acts as a container for a picture control. I am
drawing pictures in the picture control, and would like to add print
preview and print functionality - but I don't know how to do this.
i would be grateful if someone could provide a code snippet that shows
how I may ;
1). print preview an image displayed in a picture control
2). print the image displayed in the picture control
- 7
- Visual Studio C++ >> Seeking opinions of best practice on splitter windowsHello
When having a splitter window, i.e. a window that is about 5 pixels wide and
goes between the left-hand treeview and the right hand control, be it mdi
client window or listview or whatever, is it generally preferred practice to
have the left and right windows resize as the user is dragging the splitter
window, or to wait until the splitter window is dropped.
I notice that most Microsoft applications (e.g. Windows Explorer, Outlook
Express) go for the former, however it seems Visual Studio .NET adopts the
latter strategy.
I've coded my application so that it works like Visual Studio .NET. However
I can't make the splitter window adopt that transparent-gray crosshatch
pattern when it is being dragged, anybody know off-hand what the background
needs setting to to make it like that?
And also, which is the 'best-practice' method, or doesn't it generally
matter either way?
- 8
- 9
- Visual Basic [VB] >> Class controling form settingsI am wondering if it is possible to make something like the following work:
Public Class myTestSettings
Public Property onTop() As Boolean
Get
Return Form1.CheckBox1.Checked
End Get
Set(ByVal Value As Boolean)
Form1.CheckBox1.Checked = Value
End Set
End Property
End Class
Second question: if it is possible, is it advisable?
I am wanting to serialize this information to an XML file. I'm exploring
this as a possibly better way to accomplish this.
Thanks in advance,
Matthew
- 10
- 11
- Visual Basic [VB] >> socket.EndAccept(ar) is Exclusive....any way to change?Hi, im making an AIM like server using TCP sockets, however i found a big
issue. when a socket is connected to (socket.EndAccept(ar)), its already
bound to a Port. since its bound, i cannot change its access to non
exclusive, but i need this port to still be open because i may need another
socket to connect on this port as well. how can i achieve this?
--
-iwdu15
- 12
- Visual Basic >> PDW Msg "...already been added..."When packaging my project, I am asked to "choose the folder where your
package will be assembled." I click the "New Folder" icon and make a folder
and select next. There is a processing delay (only 550MHz machine) and the
drive rattles, then I am prompted with "Afile with this name has already
been added to the list of files." You only have the choice to click OK.
Does anyone know what causes this message?
Regards,
Jim
- 13
- VB Scripts >> Accessing a c#.net created COM object in vbscript...Hey guys.
How do I access a COM object in vbscript?
I created the object using c#, but am unsure :
- which guid to use
- which object id
- whether i should use the <OBJECT> tag at all
- how to handle create object...
my structure for the COM object is as follows ( created following the
tutorial found at http://www.csharphelp.com/archives/archive281.html )
//----------------------------------------- start c# code
namespace BIF_COM_API
{
//
// Interface Declaration
//
[Guid("49B9D855-182A-4064-A362-95D7D10C4E15")]
public interface BIF_Interface
{
//
// DispId declarations
//
}
//
// Events Interface
//
[Guid("09603A1F-E672-4460-9F66-D012CE9F9842"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface BIF_Events
{
}
//
// COM object instantiation
//
[Guid("1995FED2-2C21-4659-A5E4-B832C0BD4434"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof( BIF_Events ))]
public class BIF_Instantiation : BIF_Interface
{
//
// class implementation
//
}
}
//----------------------------------------- end code
and my current vbscript code is
//----------------------------------------- vbscript code
<!-- header stuff -->
<SCRIPT LANGUAGE="VBScript">
<!--
option explicit
sub VB_Click
Dim bifapi
bifapi = CreateObject ( "BIF_Instantiation" )
' error here, can't create
object
bifapi.SetDestinationQueueName "Local_In"
bifapi.Send
end sub
-->
</SCRIPT>
</HEAD>
<OBJECT
classid="clsid:49B9D855-182A-4064-A362-95D7D10C4E15"
id=BIF_COM_API.BIF_Interface
VIEWASTEXT>
</OBJECT>
<BODY>
<!-- body stuff.... -->
//----------------------------------------- end code
thanks for your help in anticipation.
Daniel.
- 14
- MFC >> Tooltip causes an ASSERT() in a child dialog boxHello experts,
I already posted about my problem a couple of days ago, but it's not
solved yet and I have some more details about it.
Using MS VC 6.0 and Vista.
I create a CTabCtrl control in a dialog box. For each tab, a child
dialog box contains a bunch of controls (CEdit, CComboBox...). I can
display tooltips for each control, no problem.
The problem is that when the cursor (I mean the mouse) leaves a
control, if it enters the tooltip area, I get an ASSERT() warning:
In WinCore.cpp
void CWnd::AssertValid() const
{
...
// should be a normal window
ASSERT(::IsWindow(m_hWnd));
...
}
This occurs only when the dialog boxes displayed in the tabs are CHILD
dialog boxes. If I choose "Overlapped" or "Popup", it works (but I
need a child dialog box).
What should I do to avoid this problem?
TXS
Phil
- 15
- Visual Basic [VB] >> Using VB 6.0 Interface in vb.net causes a problemHi,
I have an interface in vb 6.0. It has a property set member, which takes a
parameter by reference. When I try to implement this interface in my vb.net
project it gives me an error saying that "cannot implement property set
because there is no matching property on interface". I think .NET does not
allow parameter to be passed ByRef in property statements.
here is my property set statement in vb 6.0 interface called IName
Property Set Name(ByRef objName as object)
End Property
VB.NET code looks like this
Public WriteOnly Property Name() as System.IntPtr implements IName.Name
Set (ByVal value as System.IntPtr)
end set
End Property
There is an underline below IName.Name. When I put my mouse over it then it
says "Cannot implement IName.Name because there is no matching property on
Interface IName". I tried changing the System.IntPtr to System.Object but it
gives the same result. I cannot change vb 6.0 interface to accept parameter
ByVal instead of ByRef because then, I have to change all other existing
components that already are implementing this interface.
Your help is appreciated.
Thanks
|
| Author |
Message |
Llurker

|
Posted: Mon Jan 19 09:47:43 CST 2004 |
Top |
VB Scripts >> Variables from one script to another
Hi...
I posted this before, but probably didn't explain my self well...
I need to have a script that declares and sets a value for some vb
variables, and want to have the value in these variables available in other
script...
Here is what I do :
I have a master script that calls other scripts...
1st script called from master script, it declares and sets values for some
variables ...
ex : Public appver1
appver1 = "V9_4_2"
2nd script called from master script would use the variables set in 1st
script to do execute actions with it...
ex : WshEnv("Var1") = appver1
How can this be done ...
The value is "appver1" is not necessary outside of the vb environment...
Reason is that 1st script will be modified by a lot of people, but don't
want them to modify other script...
Thanks very much !!!
--
--
Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
IT Training and Consulting
www.formationhy.com
EMail@HideDomain.com
Visual Studio207
|
| |
|
| |
 |
Joe

|
Posted: Mon Jan 19 09:47:43 CST 2004 |
Top |
VB Scripts >> Variables from one script to another
Hi,
"Houman Yahyaei" <EMail@HideDomain.com> wrote in message
news:#MQPO$EMail@HideDomain.com...
| Hi...
| I posted this before, but probably didn't explain my self well...
|
| I need to have a script that declares and sets a value for some vb
| variables, and want to have the value in these variables available in
other
| script...
|
| Here is what I do :
| I have a master script that calls other scripts...
| 1st script called from master script, it declares and sets values for some
| variables ...
| ex : Public appver1
| appver1 = "V9_4_2"
|
| 2nd script called from master script would use the variables set in 1st
| script to do execute actions with it...
| ex : WshEnv("Var1") = appver1
|
| How can this be done ...
| The value is "appver1" is not necessary outside of the vb environment...
| Reason is that 1st script will be modified by a lot of people, but don't
| want them to modify other script...
|
| Thanks very much !!!
|
| --
| --
| Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
| IT Training and Consulting
| www.formationhy.com
| EMail@HideDomain.com
As a script, VBS has no ability to create data sinks, as such. There are
four basic methods to pass data among separate scripts:
1) Primary/secondary scripts run other scripts with data arguments and/or
get limited return through the Quit long integer code.
2) Primary/secondary scripts create session environmental variable(s) that
can be accessed from other scripts.
3) Primary/secondary scripts create temporary file(s) that can be accessed
from other scripts.
4) Michael Harris' IePipe solution:
Primary script creates an Ie.App window which does not have to be set as
visible. It can contain both data variables and embedded routines for the
secondary scripts. Secondary scripts get Ie.App object instance through the
ShellApp.Windows object collection and use the nominal window as a singleton
object instance to pass data back and forth through variables or run common
routines.
Joe Earnest
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 09-23-03
|
| |
|
| |
 |
Houman

|
Posted: Mon Jan 19 12:36:08 CST 2004 |
Top |
VB Scripts >> Variables from one script to another
Could you explain a bit more number 2 and 4...
They both seem interesting...
Thanks !!!
--
--
Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
IT Training and Consulting
www.formationhy.com
EMail@HideDomain.com
"Joe Earnest" <EMail@HideDomain.com> wrote in message
news:%EMail@HideDomain.com...
> Hi,
>
> "Houman Yahyaei" <EMail@HideDomain.com> wrote in message
> news:#MQPO$EMail@HideDomain.com...
> | Hi...
> | I posted this before, but probably didn't explain my self well...
> |
> | I need to have a script that declares and sets a value for some vb
> | variables, and want to have the value in these variables available in
> other
> | script...
> |
> | Here is what I do :
> | I have a master script that calls other scripts...
> | 1st script called from master script, it declares and sets values for
some
> | variables ...
> | ex : Public appver1
> | appver1 = "V9_4_2"
> |
> | 2nd script called from master script would use the variables set in 1st
> | script to do execute actions with it...
> | ex : WshEnv("Var1") = appver1
> |
> | How can this be done ...
> | The value is "appver1" is not necessary outside of the vb environment...
> | Reason is that 1st script will be modified by a lot of people, but don't
> | want them to modify other script...
> |
> | Thanks very much !!!
> |
> | --
> | --
> | Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
> | IT Training and Consulting
> | www.formationhy.com
> | EMail@HideDomain.com
>
> As a script, VBS has no ability to create data sinks, as such. There are
> four basic methods to pass data among separate scripts:
>
> 1) Primary/secondary scripts run other scripts with data arguments and/or
> get limited return through the Quit long integer code.
>
> 2) Primary/secondary scripts create session environmental variable(s)
that
> can be accessed from other scripts.
>
> 3) Primary/secondary scripts create temporary file(s) that can be
accessed
> from other scripts.
>
> 4) Michael Harris' IePipe solution:
> Primary script creates an Ie.App window which does not have to be set as
> visible. It can contain both data variables and embedded routines for the
> secondary scripts. Secondary scripts get Ie.App object instance through
the
> ShellApp.Windows object collection and use the nominal window as a
singleton
> object instance to pass data back and forth through variables or run
common
> routines.
>
> Joe Earnest
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.521 / Virus Database: 319 - Release Date: 09-23-03
>
>
|
| |
|
| |
 |
Joe

|
Posted: Mon Jan 19 15:41:29 CST 2004 |
Top |
VB Scripts >> Variables from one script to another
Hi again,
"Houman Yahyaei" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
| Could you explain a bit more number 2 and 4...
|
| They both seem interesting...
|
| Thanks !!!
|
| --
| --
| Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
| IT Training and Consulting
| www.formationhy.com
| EMail@HideDomain.com
|
| "Joe Earnest" <EMail@HideDomain.com> wrote in message
| news:%EMail@HideDomain.com...
| > Hi,
| >
| > "Houman Yahyaei" <EMail@HideDomain.com> wrote in message
| > news:#MQPO$EMail@HideDomain.com...
| > | Hi...
| > | I posted this before, but probably didn't explain my self well...
| > |
| > | I need to have a script that declares and sets a value for some vb
| > | variables, and want to have the value in these variables available in
| > other
| > | script...
| > |
| > | Here is what I do :
| > | I have a master script that calls other scripts...
| > | 1st script called from master script, it declares and sets values for
| some
| > | variables ...
| > | ex : Public appver1
| > | appver1 = "V9_4_2"
| > |
| > | 2nd script called from master script would use the variables set in
1st
| > | script to do execute actions with it...
| > | ex : WshEnv("Var1") = appver1
| > |
| > | How can this be done ...
| > | The value is "appver1" is not necessary outside of the vb
environment...
| > | Reason is that 1st script will be modified by a lot of people, but
don't
| > | want them to modify other script...
| > |
| > | Thanks very much !!!
| > |
| > | --
| > | --
| > | Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
| > | IT Training and Consulting
| > | www.formationhy.com
| > | EMail@HideDomain.com
| >
| > As a script, VBS has no ability to create data sinks, as such. There
are
| > four basic methods to pass data among separate scripts:
| >
| > 1) Primary/secondary scripts run other scripts with data arguments
and/or
| > get limited return through the Quit long integer code.
| >
| > 2) Primary/secondary scripts create session environmental variable(s)
| that
| > can be accessed from other scripts.
| >
| > 3) Primary/secondary scripts create temporary file(s) that can be
| accessed
| > from other scripts.
| >
| > 4) Michael Harris' IePipe solution:
| > Primary script creates an Ie.App window which does not have to be set as
| > visible. It can contain both data variables and embedded routines for
the
| > secondary scripts. Secondary scripts get Ie.App object instance through
| the
| > ShellApp.Windows object collection and use the nominal window as a
| singleton
| > object instance to pass data back and forth through variables or run
| common
| > routines.
| >
| > Joe Earnest
Torgeir Bakken explained #2 in his response to your first post, though you
may not have understood the context. (Torgeir's earlier response inline.)
---
Hi
As long as the main script is the one that starts the other scripts, using
the
process environment will work. Create the two scripts below and run the main
script to see this (if you change the name/path of C:\SecondScript.vbs,
update
the main script's Run statement accordingly).
-------------------- Main script --------------------
Set Wshshell = CreateObject("WScript.Shell")
Set oProcessEnv = Wshshell.Environment("PROCESS")
Appvar1 = "abcxyz"
oProcessEnv("NameApp1") = Appvar1
Wshshell.Run "wscript.exe C:\SecondScript.vbs", 1, False
---------------- C:\SecondScript.vbs ----------------
Set Wshshell = CreateObject("WScript.Shell")
MsgBox "Content off NameApp1 (variant 1): " _
& Wshshell.ExpandEnvironmentStrings("%NameApp1%")
Set oProcessEnv = Wshshell.Environment("PROCESS")
MsgBox "Content off NameApp1 (variant 2): " & oProcessEnv("NameApp1")
---
For #4, take a look the thread with Michael Harris' original post:
http://www.google.com/groups?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8&newwindow=1&safe=off&th=819e016807d6b05&rnum=8
and subsequent threads (a Google advanced group search on "iepipe"):
http://www.google.com/groups?q=iepipe+group:microsoft.public.scripting.*&hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8&newwindow=1&safe=off&start=0&sa=N
The script creating the first window is in MH's original post some of the
followups. The following adds a "DimNew" function that allows any script to
create a new variable or redimension an existing array, for storage in the
IE window. You don't need that function, if you define all the variables
needed in your initial dim statement. If you do want it, an explanation of
the syntax follows the code:
---
set oIe= createobject("internetExplorer.application")
oIe.navigate("about:blank")
do: wscript.sleep 50: loop until (oIe.readyState=4)
with oIe.document
.writeLn ("<html>")
.writeLn ("<head>")
.writeLn ("<script language=""vbscript"">")
.writeLn ("dim ...")
' the following is the DimNew code
.writeLn ( _
_
"function DimNew (byval vsVars)" & vbCrLf _
& "dim viVar, vpClose, vpOpen" & vbCrLf _
& "if NOT (vartype(vsVars)=vbString) then exit function" _
& vbCrLf _
& "vsVars= replace(replace(replace(vsVars, "" "", """"), _
"";"", "",""), "":"", "","")" & vbCrLf _
& "vpOpen= instr(vsVars, ""("")" & vbCrLf _
& "do while vpOpen" & vbCrLf _
& "vpClose= instr(vpOpen +1, vsVars, "")""): _
if (vpClose=0) then exit do" & vbCrLf _
& "vsVars= left(vsVars, vpOpen -1) " _
& "& replace(mid(vsVars, vpOpen, vpClose -vpOpen +1), " _
& ""","", ""|"") & mid(vsVars, vpClose +1)" & vbCrLf _
& "vpOpen= instr(vpOpen +1, vsVars, ""("")" & vbCrLf _
& "loop: vsVars= split("","" & vsVars, "","")" & vbCrLf _
& "for viVar= 1 to ubound(vsVars)" & vbCrLf _
& "on error resume next" & vbCrLf _
& "select case instr(vsVars(viVar), ""("")" & vbCrLf _
& "case 0: execute vsVars(viVar) & ""= empty""" & vbCrLf _
& "case else: vsVars(viVar)= replace(vsVars(viVar), ""|"", "","")" _
& vbCrLf _
& "execute ""redim preserve "" & vsVars(viVar)" & vbCrLf _
& "if err then err clear: execute ""redim "" & vsVars(viVar)" _
& vbCrLf _
& "end select" & vbCrLf _
& "on error goto 0" & vbCrLf _
& "next" & vbCrLf _
& "end function")
' remainder of required code
.writeLn ("...") 'your routines
.writeLn ("</script>")
.writeLn ("</head>")
.writeLn ("</html>")
end with
---
If used, the DimNew function allows new variables or dynamic arrays to be
declared, or dynamic arrays redimensioned, in the IeApp object window script
element, using the intrinsic execute statement to create new embedded HTML
global variables. The new or redimensioned variables may then be accessed
by any of the multiple scripts that use the dialog window. The syntax of
the embedded HTML DimNew function is similar to that of the intrinsic dim
statement. A single variable name or a variable list may be used. A
variable list may be delimited by commas (,), semi-colons (;) or colons (:).
Even though arrays are declared dynamically, the specific dimensions and
element upper bounds must be provided, as if declaring a static array with a
traditional dim statement. With array variables, the function will first
try to redim preserve the variable, to allow modification of the number of
elements in the final dimension. If that fails (e.g., for new variables,
dimensional changes, or non-final dimension element bound changes), then the
array will be dynamically redimensioned using redim, and any existing data
will be lost. The function provides no return. The format is:
set oScript= oIE.document.parentWindow.document.script
oScript.dimNew variable[(...)][, ...]
An example of code used in the secondary script file is the following:
---
' insert lcased <<title>> used creating IE window
set oShell= createObject("shell.application")
set oWins= oShell.windows
on error resume next
for each oWin in oWins
do
qIe= cbool(instr(lcase(typename _
(oWin.document)), "htmldocument"))
if err then exit do
if qIe then
sTitle= trim(oWin.document.title)
if err then exit do
if (lcase(sTitle)="<<title>>") then
set oIe= oWin
exit for
end if
end if
loop until true: err.clear
next
on error goto 0
with oIe.document.parentWindow.document.script
xWshVariable= .xHtmlVariable
.xHtmlVariable= value
[return=] .HtmlFunction [(arguments)]
end with
---
There may be scoping issues if trying to pass object variables, but these
issues do not arise with simple data variables. Be sure to close the IE
window when the last script is closed or when it is no longer needed
(oIe.quit).
Joe Earnest
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 09-23-03
|
| |
|
| |
 |
Torgeir

|
Posted: Mon Jan 19 17:55:59 CST 2004 |
Top |
VB Scripts >> Variables from one script to another
Houman Yahyaei wrote:
> Here is what I do :
> I have a master script that calls other scripts...
> 1st script called from master script, it declares and sets values for some
> variables ...
> ex : Public appver1
> appver1 = "V9_4_2"
>
> 2nd script called from master script would use the variables set in 1st
> script to do execute actions with it...
> ex : WshEnv("Var1") = appver1
>
> How can this be done ...
Hi
Ok, now I see what you mean. You want to update the process environment of the
parent process from a child script, so any new child processes (scripts) from
that parent process will see those changes (made by subscript 1).
Updating the process environment of the parent process (from a child process)
with vbscript is not possible without using a 3rd party command line utility
that is able to set an environment variable in a foreign process (you will need
to feed it with the process ID (PID) of the foreign process). Setenv.exe found
at http://www.netexec.de/fs_lstools.html can do this, as well as ConSet.exe
found at http://home.pe.net/~fpw/freeware/ .
This will end up pretty messy, because to get the PID, you need a process name
that is unique, that means you need to copy wscript.exe (or cscript.exe) to
another name and use the copy to launch the main script (but not the child
scripts). This way you can e.g. use WMI from the child script to obtain the PID
to the parent.
Instead, a much easier solution is to use the VOLATILE environment for both the
writing and the *reading* (your second child script can't read it out of the
process environment, not unless the parent script is stopped and started again,
then anything previously added in the volatile environment will be seen in the
process environment).
In a way, you can say you use a registry write from child script 1 and then a
registry read from child script 2, but without using any registry methods (note
that the volatile environment is actually registry values, take a look at
registry key "HKEY_CURRENT_USER\Volatile Environment" after creating a volatile
environment variable. Another good thing with the VOLATILE environment is that
it is not persistent, it will be emptied when you log off.
For an example, put the three following vbscripts (Main, Script1 and Script2)
in the same folder and run the Main.vbs script.
'-------------- Main.vbs ----------------
Set Wshshell = CreateObject("WScript.Shell")
MsgBox "Main, will start script 1"
Wshshell.Run "wscript.exe Script1.vbs", 1, True
MsgBox "Back in main, will start script 2"
Wshshell.Run "wscript.exe Script2.vbs", 1, True
'--------------------8<----------------------
'-------------- Script1.vbs ----------------
Set Wshshell = CreateObject("WScript.Shell")
Set oVolatileEnv = Wshshell.Environment("VOLATILE")
Appvar1 = "123abcxyz"
oVolatileEnv("NameApp1") = Appvar1
'--------------------8<----------------------
'-------------- Script2.vbs ----------------
Set Wshshell = CreateObject("WScript.Shell")
Set oVolatileEnv = Wshshell.Environment("VOLATILE")
MsgBox "Content off NameApp1 in VOLATILE: " & oVOLATILEEnv("NameApp1")
'--------------------8<----------------------
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
|
| |
|
| |
 |
Houman

|
Posted: Mon Jan 19 21:17:54 CST 2004 |
Top |
VB Scripts >> Variables from one script to another
Thanks very much, will try that tomorrow...
BTW, I'm still trying to reload or update the user environment stuff...
I'm still stuck at the same point....
Thanks !!!
--
--
Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
IT Training and Consulting
www.formationhy.com
EMail@HideDomain.com
"Torgeir Bakken (MVP)" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Houman Yahyaei wrote:
>
> > Here is what I do :
> > I have a master script that calls other scripts...
> > 1st script called from master script, it declares and sets values for
some
> > variables ...
> > ex : Public appver1
> > appver1 = "V9_4_2"
> >
> > 2nd script called from master script would use the variables set in 1st
> > script to do execute actions with it...
> > ex : WshEnv("Var1") = appver1
> >
> > How can this be done ...
>
> Hi
>
> Ok, now I see what you mean. You want to update the process environment of
the
> parent process from a child script, so any new child processes (scripts)
from
> that parent process will see those changes (made by subscript 1).
>
> Updating the process environment of the parent process (from a child
process)
> with vbscript is not possible without using a 3rd party command line
utility
> that is able to set an environment variable in a foreign process (you will
need
> to feed it with the process ID (PID) of the foreign process). Setenv.exe
found
> at http://www.netexec.de/fs_lstools.html can do this, as well as
ConSet.exe
> found at http://home.pe.net/~fpw/freeware/ .
>
> This will end up pretty messy, because to get the PID, you need a process
name
> that is unique, that means you need to copy wscript.exe (or cscript.exe)
to
> another name and use the copy to launch the main script (but not the child
> scripts). This way you can e.g. use WMI from the child script to obtain
the PID
> to the parent.
>
>
> Instead, a much easier solution is to use the VOLATILE environment for
both the
> writing and the *reading* (your second child script can't read it out of
the
> process environment, not unless the parent script is stopped and started
again,
> then anything previously added in the volatile environment will be seen in
the
> process environment).
>
> In a way, you can say you use a registry write from child script 1 and
then a
> registry read from child script 2, but without using any registry methods
(note
> that the volatile environment is actually registry values, take a look at
> registry key "HKEY_CURRENT_USER\Volatile Environment" after creating a
volatile
> environment variable. Another good thing with the VOLATILE environment is
that
> it is not persistent, it will be emptied when you log off.
>
> For an example, put the three following vbscripts (Main, Script1 and
Script2)
> in the same folder and run the Main.vbs script.
>
>
> '-------------- Main.vbs ----------------
> Set Wshshell = CreateObject("WScript.Shell")
>
> MsgBox "Main, will start script 1"
> Wshshell.Run "wscript.exe Script1.vbs", 1, True
>
> MsgBox "Back in main, will start script 2"
> Wshshell.Run "wscript.exe Script2.vbs", 1, True
> '--------------------8<----------------------
>
>
> '-------------- Script1.vbs ----------------
> Set Wshshell = CreateObject("WScript.Shell")
>
> Set oVolatileEnv = Wshshell.Environment("VOLATILE")
>
> Appvar1 = "123abcxyz"
> oVolatileEnv("NameApp1") = Appvar1
> '--------------------8<----------------------
>
>
> '-------------- Script2.vbs ----------------
> Set Wshshell = CreateObject("WScript.Shell")
>
> Set oVolatileEnv = Wshshell.Environment("VOLATILE")
> MsgBox "Content off NameApp1 in VOLATILE: " & oVOLATILEEnv("NameApp1")
> '--------------------8<----------------------
>
>
> --
> torgeir
> Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of the 1328 page
> Scripting Guide: http://www.microsoft.com/technet/scriptcenter
>
>
|
| |
|
| |
 |
| |
 |
Index ‹ Visual Studio ‹ VB Scripts |
- Next
- 1
- VB Scripts >> getting remote time from vbscriptHi all.
I would like to get the time on a remote Windows host from vbscript.
I would prefer, if possible, to avoid using the NET TIME command.
I tried the LocalDateTime method provided by WMI, but that requires
administrative rights on the remote host, which is not an option for
me.
Does anyone know another way to retrieve the time remotely without
running another executable like net.exe?
Thanks,
John
- 2
- MFC >> owner of teh serial port handleHi, experts....
I need to know the application name that open a serial port (e.g. com1). My
goal is to say to the user to close the application befora run mine
Any ideas ?
Thanks in advance
- 3
- Visual Basic [VB] >> binarywriter.write loop is causing 100% cpuHi all!
I have some files that are basically a TIF with an ASCII header.
I wrote an app that reads in the file, pulls some values from the
header and writes out everything after the header as a new file.
I'm using binaryreader and binarywriter.
Everything functions fine, but the following loop causes 100% CPU
usage and I can't figure out how to get around this.
Here is a code sample that lists the declarations and the loop that's
causing the high CPU usage:
----------------------
Dim fsIn As FileStream = New FileStream(filename,
FileMode.OpenOrCreate)
Dim fsOut As FileStream = New FileStream(fsIn.Name & ".tif",
FileMode.Create)
Dim binWriter As BinaryWriter
Dim binReader As BinaryReader = New BinaryReader(fsIn)
binWriter = New BinaryWriter(fsOut)
Do While binReader.BaseStream.Position <
binReader.BaseStream.Length
binWriter.Write(binReader.ReadByte)
Loop
binWriter.Flush()
binWriter.Close()
binReader.Close()
binReader = Nothing
fsIn.Close()
fsIn = Nothing
fsOut.Close()
fsOut = Nothing
----------------------
Obviously I left some stuff out, but that's the part that's using the
CPU.
The binReader.BaseStream.Position picks up where the loop to find the
end of the header left off.
If anyone has any suggestions or tips as to what's going on and / or
how I can get around it I'd really appreciate it!
Thanks!
- 4
- 5
- MFC >> newbie quesion on missing clw fiileHi,
I downloaded several VC++ projects from Internet, I am able to open them
using VC++ 6.0, but when I tried to open class wizard, I got error message
that the clw file is missing, do I want to build it from the source files.
When I click yes, I saw all the .cpp, .h ... My quesion is, which files
should I choose to build the clw file?
TIA
- 6
- Visual Basic >> How to move cursor position by code ?Hi all
Is that possible to move cursor position by code inside picture box.
I have set picturebox.scale (0,1000)-(1000,0)
How do I move cursor Automatic by code
For eg. I have to set cursor in 100,500 in picturebox
Thanks
Amrit
- 7
- Visual Basic [VB] >> xlSheet.get_range not thereI'm trying to use the get_range method on an Excel sheet, but when I type
'xlSheet.' I don't see the method in the drop-down. I see Cells, Name, etc,
but I don't see any method starting with a "g". This is my code:
Dim workbook As Excel.Workbook =
workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet)
Dim xlSheet As Excel.Worksheet = CType(workbook.ActiveSheet, Excel.Worksheet)
xlSheet.get_Range(.......) 'I CAN'T DO THIS
I do have "get_range" available in my C# project, but not VB project.
According to documentation it should be available for VB as well. I don't
know what I'm doing wrong.
I would appreciate your help. Thank you!
- 8
- 9
- Visual Basic >> Storing/Loading queriesHi all,
In my VB application, I have some listviews and some
comboboxes. The code forms a query based on the values
selected in these components and queries a database.
Now, I want to give the user the facility of saving and
loading queries, that is, when a user selects a stored
query the corresponding values should be shown selected in
the list boxes and comboboxes.
Could anyone give me an idea about how to go about it, as
to how should I store these queries (in files or in the
databse itself) and how to populate the components based
on these queries, when they are loaded? Or where could I
find a sample of code doing similar stuff.
Pranav
- 10
- 11
- Visual Basic >> API calls and &H1, &H2, &H4, &H8, ..., &H10, ..., H40000, ....Okay, I came into VB without *ever* learning about the hexadecimal notation.
What do the following mean and what decimal numbers do they translate to?
&H10 (is this equal to 16?)
&H400 (is this equal to 256?)
If they are, why do I use these in API calls in lieu of 16 and 256?
Thank you ever so much!
--
Joe
VBA Automation/VB/C++/Web and DB development
- 12
- 13
- MFC >> Multithreading, Converting a Byte Array to a Hex String, Simultaneously..So.. my problema: I'm reading in a massive amount of data into a BYTE
array buffer (size 64096 bytes, and about 1MB every 5 seconds) and
writing to a file. I want to grab the info, translate it into hex, and
spit it back out on the screen to display what I am receiving. So far
I have a thread doing the receiving and writing to file, and another
thread which is supposed to be translating and spitting out to a
multiline edit box.
This is probably not a good way to do it, and I was wondering if anyone
knew a better way?
Thx,
kefkastudio
- 14
- Visual Basic >> send parameters to an oracle reportHello,
I want to call an oracle report from VB6. I have added the
OracleReportingControl and set everything. I can only set one value for the
UserDefinedparameters attribute.
How can I set all the parameters that I have in my Oracle Report from VB6?
Thank you,
Moji
- 15
|
|
|