How to make a folderitem global?
The customer will be browsing to a pic, then hitting print
which will place that pic in position on a sheet to be printed.
I’ve done this before with a tsv:
[code]Dim f As FolderItem = GetOpenFolderItem(tsv)
If f <> Nil Then
CountFile.Text = f.NativePath[/code]
And then this to access the found file:
Dim f As FolderItem = GetFolderItem(CountFile.Text , 3)
[quote=158302:@Joel Godin]How to make a folderitem global?
The customer will be browsing to a pic, then hitting print
which will place that pic in position on a sheet to be printed.
I’ve done this before with a tsv:
[code]Dim f As FolderItem = GetOpenFolderItem(tsv)
If f <> Nil Then
CountFile.Text = f.NativePath[/code]
And then this to access the found file:
Dim f As FolderItem = GetFolderItem(CountFile.Text , 3)
What is a better way?
Thanks[/quote]
Add a f FolderItem property to a module, make it global, and instead of dim, go
[code] [code]f = GetOpenFolderItem(tsv)
If f <> Nil Then
CountFile.Text = f.NativePath[/code][/code]
Be careful not to reuse the same f property without making sure it is not needed anymore elsewhere. That is the big problem with global variables, bugs can be created by modifying variables you expect somewhere else to have another value.
[quote=158313:@Joel Godin]Sweet. That worked.
Just learning, so for each global item I want, I have to create a module?
Thanks.[/quote]
No, you can put your globals into one module.
[quote=158313:@Joel Godin]Sweet. That worked.
Just learning, so for each global item I want, I have to create a module?
Thanks.[/quote]
Hello,
No, you can store as many properties and methods as you want in a module. But that’s not always ideal.
For example, in large projects people tend to use different modules to organize things within the project.
Also, if you are going to reuse part of your code in another application it is easier to streep it out if you have the code for a certain task sepparated from the rest.
I see Julen. So for example if I had a long list of labels, I could put those in a module.
(separate question I know, but I have a project with about 160 labels.)
[quote=158321:@Joel Godin] So for example if I had a long list of labels, I could put those in a module.
(separate question I know, but I have a project with about 160 labels.)[/quote]
In that case use an array of labels or a dictionary depending on your needs. I try to avoid declaring globals in modules and follow OOP encapsulation paradigm of self contained and independent/reusable classes. Shared Properties or Getters/Setters (computed properties) are very useful, specially when dealing with large projects.
Thanks Amando, I will bone up on array of labels and dictionaries then. More used to C, so getting used to OOP and it’s paradigms.
Thanks Dave on the window scope.
Thanks to all for your answers, very helpful.