Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

[51] Variables

Last post 04-17-2004 7:37 AM by jawsper. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [51] Variables

    This thread is for discussions of Variables.

    • Post Points: 0
  • 04-24-2002 12:38 PM In reply to

    • ccortez
    • Not Ranked
    • Joined on 04-24-2002
    • New Member
    • Points 15

    Scope for all forms in the project

    Please, how to declare a variable that can be  accessed and changed in all procedures in all the forms in a project?

    Thanks
    • Post Points: 0
  • 05-18-2002 6:39 PM In reply to

    to make a varible avilble in all forms use this;

    public VarName as string

    not

    dim VarName as string

    then you can use it on all forms and modules

    example;  form1.VarName = something
    • Post Points: 0
  • 09-22-2002 1:07 AM In reply to

    My Variables are getting chopped off!

    I am trying to make a program and when I set a variable with a long value and a portion of its value gets chopped off.  The shorter variables values get extra characters added to the end.  How do I fix this?

    It works fine if I hard code the variable into the program but I need to get it from an ini file and use it.

    Thank you in advance.

    Joel Strellner
    • Post Points: 0
  • 08-05-2003 12:50 PM In reply to

    • jawsper
    • Not Ranked
    • Joined on 04-11-2003
    • Junior Member
    • Points 25

    String to Object

    i have a string from a file, and i want it to be the object name. how can i do that?
    ----------------------------------
    so, why arent you reading my extremely interesting post above? ;)
    • Post Points: 0
  • 08-05-2003 1:24 PM In reply to

    • LouisRose
    • Top 75 Contributor
    • Joined on 02-20-2002
    • Fanatic Member
    • Points 1,255
    I don't think you can do this.

    Why do you want to? Describe the situation and perhaps we can come up with a different solution.
    • Post Points: 0
  • 08-05-2003 1:29 PM In reply to

    • jawsper
    • Not Ranked
    • Joined on 04-11-2003
    • Junior Member
    • Points 25

    New solution

    I already tought of a solution.

    The original plan was to have a text file, with the data (it's supposed to be a multi-language support, with text-files that contain the strings for like the menu's) in order: objName = value.

    This didn't work, so i used a bit harder method with a select case the when the object name is found, the string is used, for example:
    Case "mnuHelp": mnuHelp.Caption = info(1)
    the info(1) is the string after the "=" char.

    This works good now, maybe i will make it a bit better lateron, but now i'm gonna focus on making the real program (a better notepad).

    Thanks anyways.
    ----------------------------------
    so, why arent you reading my extremely interesting post above? ;)
    • Post Points: 0
  • 08-05-2003 1:48 PM In reply to

    • LouisRose
    • Top 75 Contributor
    • Joined on 02-20-2002
    • Fanatic Member
    • Points 1,255
    I'm glad that you came up with a solution.

    For muti-lingual support you best bet is to use a Resource file. Then the User's language and Locale will be detected automatically and your program will be capable of dealing with these details on-the-fly.

    If you the MSDN collection installed there is a rather good chapter in the Visual Basic section describing how best to use Resource Files.

    Hope this helps.
    • Post Points: 0
  • 03-01-2004 2:03 AM In reply to

    • Rde
    • Not Ranked
    • Joined on 03-01-2004
    • New Member
    • Points 10
    The following lists the public, private, and default visibility
    for the various elements you can declare in your programs.

    Default means declaring without anything proceding (or with Dim
    in the case of variables) rather than with Public or Private.

                       Standard Module    Form and Class Modules
                       ============================
    Constants      Default private    Default private
                         Private OK         Private OK
                         Public OK          Public illegal

    User-defined types  Default public     Default illegal
                         Private OK         Private required
                         Public OK          Public illegal

    Declare statements  Default public     Default illegal
                         Private OK         Private required
                         Public OK          Public illegal

    Variables           Default private    Default private
                         Private OK         Private OK
                         Public OK          Public creates property

    Functions and subs  Default public     Default creates method
                         Private OK         Private OK
                         Public OK          Public creates method

    Properties          Default public     Default public
                         Private OK         Private OK
                         Public OK          Public OK
    • Post Points: 0
  • 03-01-2004 4:12 PM In reply to

    • cwamsley
    • Not Ranked
    • Joined on 03-01-2004
    • New Member
    • Points 5

    String to Object Continued

    Louis,

    I am working on a somewhat similar problem (to the String to Object comments from Aug 5, 2003) and hope you can suggest a course of action.

    I'm trying to create a simple way to set and modify the values in multiple combination boxes. My plan is to have a sheet containing the combobox names in cells A .. n and the selection choices to be in rows 2 .. m.  

    CB1    CB2
    A1        A2
    B1        B2
    C1        C2

    In my VB code, I would like to use something like CBname = StringtoObject(Range("A" & m).value) so that I can loop through columns A to n and pass CBname as the combobox name to another procedure.  Another possibility might be for CBname to point to the CB1 address, but I'm not sure how to do this in VB. Do you have any suggestions?
    • Post Points: 0
  • 03-02-2004 2:35 AM In reply to

    • LouisRose
    • Top 75 Contributor
    • Joined on 02-20-2002
    • Fanatic Member
    • Points 1,255
    Hey cwamsley,

    Welcome to DevFusion!

    This sounds like a control array problem - if you're using VB (and not .NET) that is. You can have several controls with the same name, but with an index, like a normal array. For example,

    cboSelection(0), cboSelection(1), cboSelection(2), ..., cboSelection(n)

    Then the procedure which needs to know the name of the combobox need only be told an index, and can do something like:
    cboSelection(intIndex)

    to select the correct combobox object.

    The easiest way to create a control array, is to select the combo box in Form View, click Edit | Copy, click Edit | Paste and click Yes when asked whether or not you would like to create a control array.

    Control arrays are a complex topic, but have many, many uses. I recommend you consult the manual to clarify my explaination, and to cover the topics I simply do not have the time to write about!

    Good luck.
    • Post Points: 0
  • 04-17-2004 7:37 AM In reply to

    • jawsper
    • Not Ranked
    • Joined on 04-11-2003
    • Junior Member
    • Points 25

    new solution

    i just found out how i can make my original idea work.

    i read something about the "eval" function in the microsotf script controls, so now ik kan just say: ScriptControl1.Eval(line) and it will finally work as i planned before
    ----------------------------------
    so, why arent you reading my extremely interesting post above? ;)
    • Post Points: 0
Page 1 of 1 (12 items)