Global variable visual basic

Chris Milam 1 Reputation point
2021-12-02T10:43:17.79+00:00

First off I'm a beginner programmer with little schooling to date, but that's changing soon. Anyway, I'm working on a personal project at current time and I'm trying to declare some global variables to be used across multiple forms(restaurant management application) buy I can't seem to get them to work. I've put them in a module bug I don't knowvif I'm calling them correctly. I use I use Public variable As Datatype in the module.

Developer technologies | VB
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 91,416 Reputation points
    2021-12-02T11:01:01.17+00:00
    0 comments No comments

  2. Jiachen Li-MSFT 34,231 Reputation points Microsoft External Staff
    2021-12-03T05:40:14.323+00:00

    Hi @Chris Milam ,
    You can use Public only at module, interface, or namespace level. This means the declaration context for a Public element must be a source file, namespace, interface, module, class, or structure, and cannot be a procedure.
    You can refer to this documentation Public (Visual Basic)
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.