Can anyone tell me how to set a string globally?
Many thanks
Printable View
Can anyone tell me how to set a string globally?
Many thanks
Form wide - Put the line with "dim" in the general declarations section
Project wide - Put this line in a module
Code:Public WhatEver As String
Whats form wide? i'm not really VB man?
Many Thanks
oetje is talking about scope.
If you want your variable to be accessed and changed from ANYWHERE in your project (all forms, classes, modules, ect.) then declare it as Public in a module.
If you want your variable to be accessed and changed from any procedure in a form, but NOT the other forms/modules in your project then declare it Private (or Dim) in the General Declarations section of the form only.
Generally you want to give your variables as little scope as necessary so that they are safe from being changed by those who have no business changing them.
Hope that helps,
CHEERS