Results 1 to 8 of 8

Thread: Calling Module variables.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Location
    Wisconsin
    Posts
    81

    Resolved Calling Module variables.

    I have to start off by saying that I'm used to working with VB 6.0 from high school and that experience has carried just about the whole way through my college course with a few hiccups here and there.

    I believe I'm supposed to create a variable called mRaceName (should hold "Kentucky Derby"), and then read in the Horse information (1: Circular Quay, 9-5;Happy) in as an array.

    This is one of the module strings:

    Public Race01() As String = {"Kentucky Derby, derby.jpg", _
    "1: Circular Quay, 9-5;Happy", _
    "2: Stormello, 5-1;Bashful", _
    "3: Cobalt Blue, 30-1;Snow White", _
    "4: Crudacious, 6-5;Bozo", _
    "5: Take Five, 5-1;Wet Willie", _
    "6: Big Loser, 0-0;Duncell", _
    "7: Bongo Monkey, 3-1;Bashful", _
    "8: Tripoli, 21-1;Jack Beabstalk"}

    The book I have doesn't discuss modules other than mention them as a "collection of code stored in one file"

    Thank you very much for ANY help you can offer me.
    Last edited by jrowe; Dec 4th, 2007 at 10:16 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Calling Module variables.

    Welcome to the Forums.

    Modules are just like they were in VB 6. Probably one of the few things that was retained.

    You could use a collection in a class to dynamically add your items to it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Location
    Wisconsin
    Posts
    81

    Re: Calling Module variables.

    You'll have to forgive me, but I'm not very good with classes and I don't remember ever using a module in VB 6.0 the 4 years ago I had the class.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Calling Module variables.

    If you declare it as "Public" then it will be accessible throughout your app but usually not the best for OOP design/logic.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Location
    Wisconsin
    Posts
    81

    Re: Calling Module variables.

    So are you saying I could just declare a variable called mRaceName and use a substr() fucntion to take the beginning section and put Kentucky Derby into the mRaceName value, or that I would need to take that Race1() string and read it into a public variable I declare in the Form code?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Location
    Wisconsin
    Posts
    81

    Re: Calling Module variables.

    I tried to put the string from the module into a global variable and got - Value of type '1-dimensional array of String' cannot be converted to 'String'.
    Not really sure where to go from here.

  7. #7
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: Calling Module variables.

    That means your trying to set an array to a string, or a string to an array, can you post the code you got this error on please.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Location
    Wisconsin
    Posts
    81

    Re: Calling Module variables.

    the code I was getting it on I have fixed. I've actually figured out my problem for this part of the assignment at least. If I would have spent another 10 minutes tinkering I would have found it. Thank you to everyone who replied.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width