Just rereading your original post, are you adding labels that already exist on your form, or are you need to dynamically add them? If you are just adding a group of existing labels you could do this:
'make the collection
Dim lbs As New List(Of Label)
'add the labels
lbs.AddRange(New Label()...
Easier to add/remove collection items, in my opinion. The code looks cleaner and makes more sense - to me. So I guess I should have said IMHO. Wasn't trying to offend.
Do you mean the code you have from earlier that does not work? That's why i posted a different solution - one that works better than an array. Do you need more info on how it works?
The framework is your version of VS. 2008 is FW 3.5, 2005 is FW 2.0. Meaning as long as you are using VS2005 or later the Generics List(Of T) is available for you. This is a great new class that in my mind replaces ArrayList - it helps avoid casting errors as it is a type specific collection.
As long as you are using framework 2.0 or > then:
'class declaration, type specific collection/no need to cast the type
Dim myLabels As New List(Of Label)
For i As Integer = 1 To 10
Dim l As New Label
'add stuff to properties
myLabels.Add(l)
Next
'index access
myLabels(0).Text =...
The easiest thing to do is Google 'vb.net word automation' and whatever you do - do not use CreateObject just use the new keyword and you will be fine. Remember to release the Com object or the process will not close.
Has anyone messed around with this; if I add the Word object library 12.0 (Word 2007), work with some 97-2003 templates (which works fine on my computer) will incur any issues when a client's computer has Word 2003 and not Word 2007 - due to the object library? Thanks...
I am with Bob, and if you have several groups that need the same location you can stack the panels on the same location and use the BringToFront() property of the panel you want to show.
That is strange, mine does not do that. The only real difference I can see is I don't use CreateObject. I just Dim oWord as New Word.Application. CreateObject can be hard to close, have you checked your processes to make sure it is ending? If you are having trouble with that part try this sub...
I have added a schema to my word doc, and placed the elements in the doc. How do I fill the word doc via an Xml that is the same format? I am using VB.Net automation. Thanks
Can be, like with VbCrLf does not always work(linux), but Environment.NewLine will. The same thing goes for file locations if you store stuff in the localAppdata file(which is common) the path may fail, but Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) will work for all...
agooddatamgr, thank for replying, but I am well aware of that. I am not a noob, just found something that is not working as it should. If you read my posts you will see I already said what you said, but I don't want an "*". Anyway the problem is resolved.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.