?
Solved

Script control Procedures

Posted on 2003-02-23
7
Medium Priority
?
214 Views
Last Modified: 2010-04-07
Hello,
I have this text in a textbox that I need to have a script control execute.

'-----------------------
Public Z As Integer

Function X(y As Integer) As Integer
  Z = Y + Z
End Function

Function W(y As Integer) As Integer
  Z = Y - Z
End Function
'------------------------

I need to have the code added to a script control and then be able to call the functions while retaining the Z value.  Is this possible?

Thanks!
Brett
0
Comment
Question by:brspurri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:Gunsen
ID: 8004463
I do not know why you have them called functions since the do not return anything, ie: X=Z or W=Z, thus i have made them Sub's in this sample:

  F = F & "Sub X(y)" & vbCr
  F = F & "Z = Y + Z" & vbCr
  F = F & "End Sub" & vbCr
  F = F & "Sub W(y)" & vbCr
  F = F & "Z = Y + Z" & vbCr
  F = F & "End Sub" & vbCr
  ScriptControl1.AddCode F
 
  ScriptControl1.ExecuteStatement "Z=2"
  ScriptControl1.ExecuteStatement ("X(1)")
  ScriptControl1.ExecuteStatement ("W(1)")
  MsgBox ScriptControl1.Eval("Z")
0
 

Author Comment

by:brspurri
ID: 8004564
What about the "Public Z As Integer"? I need to keep track of the value of Z as each sub is called.  And thank you, I meant to call them Subs.

-Brett
0
 
LVL 3

Accepted Solution

by:
Gunsen earned 400 total points
ID: 8005248
Sorry, the Z was missing from my copy-paste...
Add to the top:
F = "Dim Z"

Then the Z will remain persistent.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:brspurri
ID: 8005279
Thank you!  One more thing though.  Do you know if you can use Public to reference variables in other modules of the script control (ie: ScriptControl1.Modules("ModA")) ?

Thanks!
0
 
LVL 3

Expert Comment

by:Gunsen
ID: 8007004
I dont believe you can.
0
 

Expert Comment

by:CleanupPing
ID: 8901246
brspurri:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8964177
Moderator, my recommended disposition is:

    Accept Gunsen's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question