Results 1 to 7 of 7

Thread: Class Variable Issue

  1. #1

    Thread Starter
    Fanatic Member jcavard's Avatar
    Join Date
    Jul 2005
    Location
    Quebec, CANADA
    Posts
    534

    Class Variable Issue

    Question 1:
    Hi! I have an application that loads tons of picture into a listview. While it'S loading, the images loaded in the listview tend to appears and disappears. I would like to know if there is anyway I can "Freeze" the window while the images load, then refresh it... so the user wouldn't see that "bug". It would also allow the user to do anything until it's loaded, to avoid memory crashes... Thank You!
    _________________________________________________________________

    Question 2:
    My Application has to be French and English. So I thought I was going to load the table corresponding to the language selected and store the language string into String variable, like:
    VB Code:
    1. Public MENU_ABOUT As String = CStr(datarow(0)) ' which is "About..."
    2.     Public MENU_ALWAYS_ON_TOP As String = CStr(datarow(1)) ' which is "Always on Top"
    3.     ...
    And I assign the Vakue to the component at runtime...
    VB Code:
    1. '
    2.         'mnuFile
    3.         '
    4.         Me.mnuFile.Enabled = CType(resources.GetObject("mnuFile.Enabled"), Boolean)
    5.         Me.mnuFile.Index = 0
    6.         Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNewCollection, Me.mnuProperties, Me.mnuPrint, Me.mnuPrintSetup, Me.MenuItem13, Me.mnuImportFiles, Me.MenuItem14, Me.mnuMainExit})
    7.         Me.mnuFile.Shortcut = CType(resources.GetObject("mnuFile.Shortcut"), System.Windows.Forms.Shortcut)
    8.         Me.mnuFile.ShowShortcut = CType(resources.GetObject("mnuFile.ShowShortcut"), Boolean)
    9.         Me.mnuFile.Text = [B]MENU_FILE[/B]  
    10.         Me.mnuFile.Visible = CType(resources.GetObject("mnuFile.Visible"), Boolean)
    But I get Warning (it's not error because I still can run the application). I atached a screenshot. Why do I have all this saying "The variable is either undeclared or was never assigned" when THEY ACTUALLY ARE DECLARED AND ASSIGNED in module called LANG.

    Thank You!
    Attached Images Attached Images  
    Last edited by jcavard; Oct 3rd, 2005 at 01:48 PM.
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    accoustic emo-rock band: a tailormade fable

    Visual Studio 2003 / Framework 1.1

  2. #2
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651

    Re: <TWO IN ONE> "Freezing" Form AND Public Variable Issue

    I think its a problem of scope. I think you should declare your constants as Shared variables in a module and refer to them by prefixing the modulename. i.e
    VB Code:
    1. Public Class Globals
    2.  public Shared  MENU_FILE As String
    3.  public Shared  MENU_BLABLA As String
    4.  Public Shared SetLanguage()
    5.      If French Then
    6.        ' assign texts here
    7.         MENU_FILE = "Fichier"
    8.      Else
    9.      End If
    10.  End Sub
    11. End Class

    Then in the normal code use
    VB Code:
    1. Me.mnuFile.Text = Globals.MENU_FILE
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  3. #3

    Thread Starter
    Fanatic Member jcavard's Avatar
    Join Date
    Jul 2005
    Location
    Quebec, CANADA
    Posts
    534

    Re: <TWO IN ONE> "Freezing" Form AND Public Variable Issue

    I made a class, with the var members and the initiating sub, but I still get the same Warning.

    VB Code:
    1. Public Class Lang
    2.  
    3.     ' STATUS BAR MESSAGE
    4.     Public Shared STATUS_VIEWING_COLLECTION As String
    5.     Public Shared STATUS_VIEWING_COLLECTION_NONE As String
    6.     Public Shared STATUS_VIEWING_IMAGE_OF_NONE As String
    7.     Public Shared STATUS_VIEWING_IMAGE_OF As String
    8.     ' MSGBOX STRING
    9.     Public Shared MSGBOX_REGKEY As String
    10.     Public Shared MSGBOX_REGKEY_SUCCESSFUL As String
    11.     Public Shared MSGBOX_ERROR As String
    12.     Public Shared MSGBOX_ERROR_BLANK_LABEL As String
    13.     Public Shared MSGBOX_ERROR_WRONG_LABEL As String
    14.     Public Shared MENU_ABOUT As String
    15.     Public Shared MENU_ALWAYS_ON_TOP As String
    16.     Public Shared MENU_COPY As String
    17.     Public Shared MENU_CUT As String
    18.     Public Shared MENU_DELETE_IMAGE As String
    19.     Public Shared MENU_DSD_WEB As String
    20.     Public Shared MENU_EDIT As String
    21.     Public Shared MENU_EXIT As String
    22.     Public Shared MENU_FILE As String
    23.     Public Shared MENU_FIND As String
    24.     Public Shared MENU_HELP As String
    25.     Public Shared MENU_HELP_TOPIC As String
    26.     Public Shared MENU_IMPORT_FILES As String
    27.     Public Shared MENU_NEW_COLLECTION As String
    28.     Public Shared MENU_OPTIONS As String
    29.     Public Shared MENU_PASTE As String
    30.     Public Shared MENU_PRINT As String
    31.     Public Shared MENU_PRINTER_SETUP As String
    32.     Public Shared MENU_PROPERTIES As String
    33.     Public Shared MENU_README_FILE As String
    34.     Public Shared MENU_STATUS_BAR As String
    35.     Public Shared MENU_TOOLBAR As String
    36.     Public Shared MENU_TOOLS As String
    37.     Public Shared MENU_VIEW As String
    38.  
    39.     Public Shared Sub setLang()
    40.         STATUS_VIEWING_COLLECTION = "Viewing subject: "
    41.         STATUS_VIEWING_COLLECTION_NONE = "Viewing subject: <none>"
    42.         STATUS_VIEWING_IMAGE_OF_NONE = "Image X of Y"
    43.         STATUS_VIEWING_IMAGE_OF = "Image {0} of {1}"
    44.         MSGBOX_REGKEY = "Registry"
    45.         MSGBOX_REGKEY_SUCCESSFUL = "Registry edited successfully"
    46.         MSGBOX_ERROR = "Error"
    47.         MSGBOX_ERROR_BLANK_LABEL = "Invalid tree node label." + Microsoft.VisualBasic.ControlChars.Cr + "The label cannot be blank"
    48.         MSGBOX_ERROR_WRONG_LABEL = "Invalid tree node label." + Microsoft.VisualBasic.ControlChars.Cr + "The invalid characters are: '@','.', ',', '!'"
    49.         MENU_ABOUT = "About..."
    50.         MENU_ALWAYS_ON_TOP = "Always on Top"
    51.         MENU_COPY = "Copy"
    52.         MENU_CUT = "Cut"
    53.         MENU_DELETE_IMAGE = "Delete Image"
    54.         MENU_DSD_WEB = "DSD on the Web"
    55.         MENU_EDIT = "Edit"
    56.         MENU_EXIT = "Exit"
    57.         MENU_FILE = "File"
    58.         MENU_FIND = "Find"
    59.         MENU_HELP = "?"
    60.         MENU_HELP_TOPIC = "Help Topics"
    61.         MENU_IMPORT_FILES = "Import Files..."
    62.         MENU_NEW_COLLECTION = "New Collections"
    63.         MENU_OPTIONS = "Options..."
    64.         MENU_PASTE = "Paste"
    65.         MENU_PRINT = "Print..."
    66.         MENU_PRINTER_SETUP = "Printer Setup..."
    67.         MENU_PROPERTIES = "Properties"
    68.         MENU_README_FILE = "'ReadMe' File"
    69.         MENU_STATUS_BAR = "Status Bar"
    70.         MENU_TOOLBAR = "Toolbar"
    71.         MENU_TOOLS = "Tools"
    72.         MENU_VIEW = "View"
    73.     End Sub
    74. End Class
    and this to set the var

    VB Code:
    1. Public Sub New()
    2.         MyBase.New()
    3.  
    4.         'Cet appel est requis par le Concepteur Windows Form.
    5.         InitializeComponent()
    6.         [B]Lang.setLang()[/B]
    7.         'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
    8.  
    9.     End Sub
    10.         'mnuFile
    11.         '
    12.         Me.mnuFile.Enabled = CType(resources.GetObject("mnuFile.Enabled"), Boolean)
    13.         Me.mnuFile.Index = 0
    14.         Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNewCollection, Me.mnuProperties, Me.mnuPrint, Me.mnuPrintSetup, Me.MenuItem13, Me.mnuImportFiles, Me.MenuItem14, Me.mnuMainExit})
    15.         Me.mnuFile.Shortcut = CType(resources.GetObject("mnuFile.Shortcut"), System.Windows.Forms.Shortcut)
    16.         Me.mnuFile.ShowShortcut = CType(resources.GetObject("mnuFile.ShowShortcut"), Boolean)
    17.         Me.mnuFile.Text = Lang.MENU_FILE 'resources.GetString("mnuFile.Text")
    18.         Me.mnuFile.Visible = CType(resources.GetObject("mnuFile.Visible"), Boolean)
    Last edited by jcavard; Sep 27th, 2005 at 02:10 PM.
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    accoustic emo-rock band: a tailormade fable

    Visual Studio 2003 / Framework 1.1

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

    Re: <TWO IN ONE> "Freezing" Form AND Public Variable Issue

    You could do this.
    VB Code:
    1. Me.ListView1.BeginUpdate()
    2. 'Do stuff
    3. Me.ListView1.EndUpdate()
    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
    Fanatic Member jcavard's Avatar
    Join Date
    Jul 2005
    Location
    Quebec, CANADA
    Posts
    534

    Re: <TWO IN ONE> "Freezing" Form AND Public Variable Issue

    thanks robdogg!! ReallY!
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    accoustic emo-rock band: a tailormade fable

    Visual Studio 2003 / Framework 1.1

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

    Re: <TWO IN ONE> "Freezing" Form AND Public Variable Issue

    What if you change the order in which its called?
    VB Code:
    1. Public Sub New()
    2.         MyBase.New()
    3.  
    4.         'Cet appel est requis par le Concepteur Windows Form.
    5.         Lang.setLang()
    6.         InitializeComponent()
    7.         'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
    8.  
    9.     End Sub
    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

  7. #7

    Thread Starter
    Fanatic Member jcavard's Avatar
    Join Date
    Jul 2005
    Location
    Quebec, CANADA
    Posts
    534

    Re: <TWO IN ONE> "Freezing" Form AND Public Variable Issue

    same thing... I get an error saying Lang.MENU_FILE is not declared ...
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    accoustic emo-rock band: a tailormade fable

    Visual Studio 2003 / Framework 1.1

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