|
-
Aug 2nd, 2000, 03:02 AM
#1
Thread Starter
Addicted Member
Hi,
I try to create a OCX that contain a listbox - and i want to insert a lot of records to a listbox in design time, to save the Additem step in the listbox, also to eliminate the need of external file to be inserted to the Listbox. Is there a quick way to achive that? Is there a limit at design time, eto enter the values in to the list property of the list box? I try the 'Cut' and 'Paste" and i canot move over 1200 item, any idea?
Regards
-
Aug 2nd, 2000, 03:12 AM
#2
Lively Member
i think additem and adding it in list time takes up about the same time
YC Sim
Teenage Programmer
UIN 37903254
-
Aug 2nd, 2000, 06:56 AM
#3
Thread Starter
Addicted Member
Hi,
What is the different between UserControl_InitProperties and UserControl_Initialize ?
Regards
-
Aug 2nd, 2000, 08:19 AM
#4
From MSDN:
This event allows the author of the object to initialize a new instance of the object. This event occurs only when a new instance of an object is being created; this is to allow the author of the object to distinguish between creating a new instance of the object and loading an old instance of the object.
By putting in code to initialize new instances in the InitProperties event rather than the Initialize event, the author can avoid cases where loading data through a ReadProperties event into an old instance of the object will undo the initialization of the object.
-
Aug 2nd, 2000, 11:43 PM
#5
Thread Starter
Addicted Member
Thanks,
BTW - the limit for listbox item is - 1200 at design time and 32766 item in run time.
Thanks again
-
Aug 3rd, 2000, 01:53 AM
#6
Thread Starter
Addicted Member
Hi,
I want to fill a Listbox eith a 30000 lines of text and i want to use the List1.ItemData. Is it another index ? how can i find a list1.list(item) with specifid Itemdata?
My Itemdata is 6581091 and i like to extract the list1.listindex of it.
Regards
-
Aug 3rd, 2000, 04:40 AM
#7
transcendental analytic
ItemData is an array of numeric values that can be used as secondary values not shown in the list. You use the Itemdata property as you use List property
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 3rd, 2000, 06:10 AM
#8
Thread Starter
Addicted Member
kedaman,
I have a ItemData - 2784573 - how can i know what is the text (List1.item or list) related to that ItemDdata?
Regards
-
Aug 3rd, 2000, 06:29 AM
#9
Hyperactive Member
Walk thru all the items in a loop eg.
Code:
For i = 0 To List1.ListCount - 1
If List1.ItemData(i) = <the one i was looking for> Then
MsgBox List1.List(i)
End If
Next 'i
-
Aug 3rd, 2000, 01:51 PM
#10
transcendental analytic
That's a way to find out, but why did you lost the index in the first place if you got that value?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 5th, 2000, 11:51 PM
#11
Thread Starter
Addicted Member
kedaman,
I did not lost the index in the first place, I have a list of records and i want to extract a part of the record to the Listbox, and sort the Text - But - i want to be able to locate a line from the sotrted Listbox by the uniq (unsorted) number thet i have with the record, How can i do it?
Regards
-
Aug 6th, 2000, 01:37 PM
#12
transcendental analytic
I guess you would just have to search for it, using Crazy D's method
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 7th, 2000, 04:20 AM
#13
Thread Starter
Addicted Member
Hi,
When i add my ocx to a form its start to read the input file and insert the record to a Listbox, and when i Run my project its start to read the file again and start all over again, Why is that? how can i prevent the read of file in the design time (put the ocx on form)? how can i pass a filename to a ocx to refresh the file?
Regards
-
Aug 7th, 2000, 12:18 PM
#14
transcendental analytic
Inside the usercontrol you can use the readonly ambient.usermode property to determine if it is not in designmode:
Code:
If UserControl.Ambient.UserMode Then
'Read file
End if
I'm not sure in which way you want to pass the filename, either you should make a method in the usercontrol or store it in a module while notifying it another way, that's up to you
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 7th, 2000, 11:40 PM
#15
Thread Starter
Addicted Member
kedaman,
I put the code in the UserControl_Initialize() and i got
"Run-time error '398'
Client site not available.
???
-
Aug 8th, 2000, 07:35 AM
#16
transcendental analytic
Hmm, that's because the object hasn't been created yet, you would have to put it in another event that fires after initialization:
Code:
Private Sub UserControl_Resize()
Static Running As Boolean
If Running = False Then
If UserControl.Ambient.UserMode Then
End If
Running = True
End If
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 8th, 2000, 11:57 PM
#17
Thread Starter
Addicted Member
Thanks, i'll try it imm..
-
Aug 9th, 2000, 05:18 AM
#18
Lively Member
A cheap method?
If I got it correctly, you want to assign a long set of data to a list box prior to execution. My suggestion would be parse the data set with Excel and convert the raw data to assignment statements, so that any variable or constant arrays of desired size, could be loaded but would be embedded in code. Such as;
Field1 Field2
------ ------
data11 data21
data12 data22
data13 data23
would be;
field1(1) = data11
field2(1) = data21
field1(2) = data12
.. and so on..
I could have misintrepeted your problem, though.
Good Luck!
Kiziltan Yuceil
Freelance Web/VB/VBA Programmer
"It's not what you know it's to whom you consult and with whom you collaborate"
-
Aug 9th, 2000, 06:36 AM
#19
Thread Starter
Addicted Member
Hi,
Yes i want to assign a long set of data to a list box prior to execution, BUT as u c i have some problem with it, 1st when i add the ocx on a form - its start to load the file, 2nd when i run the project its start all over again, 3rd when i stop the project (surprise) its start again...
Well can u be more specific?
-
Aug 10th, 2000, 04:39 AM
#20
Lively Member
My trick is not to use an OCX at all!
Suggest that you have a single-table database. Convert it to csv (comma seperated values) format.
Open it with excel, and using either worksheet function or VBA coding, generate code strings which would assign data values into items of an array in VB. Like this;
Under Excel your dataset looks like this:
A B C
1 ID Name Surname
2 1 Matthew Gibbs
3 2 Sean Connery
4 3 Robert Palmer
5 4 And So On
Now Convert data to code string via Column D :
D
1 VBCode
2 ="ID("&(ROW()-1)&")="&A1&":Name("&(ROW()-1)&")="&chr(34)&B1&chr(34)&":Surname("&(ROW()-1)&")="&chr(34)&C1&chr(34)
3 ="ID("&(ROW()-1)&")="&A2&":Name("&(ROW()-1)&")="&chr(34)&B2&chr(34)&":Surname("&(ROW()-1)&")="&chr(34)&C2&chr(34)
4 ...
5 ...
These formula will show:
D
1 VBCode
2 ID(1)=1:Name(1)="Matthew":Surname(1)="Gibbs"
3 ID(2)=2:Name(2)="Sean":Surname(2)="Connery"
Now copy the stuff on the column D from Row2 to the end. Paste it into your module in VB. Now you have a code that assigns your dataset to 3 arrays. Just declare them:
Dim ID(1 To X) As Integer
Dim Name(1 To X) As String, _
Surname(1 To X) As String
Do whatever you want with these arrays, assign to Listboxes or anything...
As you have - it seems - a long list of items, I would advice this code stuff be in a seperate module. As you compile, you'll have all the stuff embedded in your main exe.
I hope, I helped..
Kiziltan Yuceil
Freelance Web/VB/VBA Programmer
"It's not what you know it's to whom you consult and with whom you collaborate"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|