Solved

Retaining a value

Posted on 2014-10-09
6
56 Views
Last Modified: 2014-10-09
I use the code below to determine a value, however later in the procedure I would like to use it again and the value is empty?  Is there a way to make this a global value so it is not lost?  Or a way to carry the value from one procedure to another?  Trying to determine just where I am losing it.

session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").Text = strValidMatlNum
0
Comment
Question by:RWayneH
[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
  • 3
  • 2
6 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40371469
You could declare strValidMatlNum as a Global variable (added outside your subroutine).  This will allow the value to be used in all modules:
Option Explicit
Global strValidMatlNum as String

Sub subroutine()
.
.
.
End Sub

Open in new window


Be sure you don't have other declarations for the same variable name elsewhere.  I will sometimes create a module exclusively for global variables.

-Glenn
0
 

Author Comment

by:RWayneH
ID: 40371675
It worked!!  Thanks... but if some reason I could not use Ln1?  I made the procedure stop at places were I was setting a variable to Y or X...  different one..  After I commented that out it worked.  Any thoughts on the Ln 1
0
 
LVL 34

Expert Comment

by:Norie
ID: 40371692
RWayneH

You should always use Option Explicit as it helps you find undeclared variables, and you should always declare your variables.:)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40371727
^ What imnorie said.    If you add the Option Explicit and then do a compile (VBA menu: Debug - Compile VBA Project) you'll be alerted to any/all undeclared variables.

-Glenn
0
 

Author Closing Comment

by:RWayneH
ID: 40371774
Thanks for the help.
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40371778
You're welcome.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

690 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