|
-
Oct 22nd, 2002, 04:14 PM
#1
Thread Starter
New Member
ListBox1.ListCount Question
hello,
i'm semi familiar with vb6 and the function of sending all my information in a listbox to the clipboard but i just cannot get it to work properly in vb.net. here is my code:
Dim x As Integer
x = ListBox1.ListCount
For x = 0 To (ListBox1.ListCount - 1)
If ListBox1.ListCount (x) = True Then GenerateText = GenerateText & ListBox1.List (x) & vbCrLf
Next
GenerateText = GenerateText & "" & vbCrLf
GenerateText = GenerateText & Text1.Text
It states
'ListCount' is not a member of 'System.Windows.Form.ListBox'
'List' is not a member of 'System.Windows.Form.ListBox'
as well as
'Text1' is not declared'
can someone shed some light on this for me ...much appreciated.
- justin
-
Oct 22nd, 2002, 04:16 PM
#2
You would have to use Items collection of the ListBox class:
ListBox1.Items.Count
-
Oct 22nd, 2002, 04:39 PM
#3
Thread Starter
New Member
yay
ok that fixed the first part of them not working but now the rest shows as following:
For x = 0 To (ListBox1.Items.Count - 1)
If ListBox1.Items.Count (x) = True Then GenerateText = GenerateText & ListBox1.Items.Count (x) & vbCrLf
Next
GenerateText = GenerateText & "" & vbCrLf
GenerateText = GenerateText & Text1.Text
End Function
when i hover over the items in green it states:
'Public Overridable Overloads ReadOnly Property Count() As Integer' has no parameters and its return cannot be indexed'
oh and Text1 still is not 'declared'.
thanks again! this forum is great.
- justin
-
Oct 22nd, 2002, 05:32 PM
#4
PowerPoster
You can't refer to an item by the count property. You're doing this:
ListBox1.Items.Count(x)
where you should be refering to the items collection itself:
ListBox1.Items(x)
Try this:
Code:
For x = 0 To (ListBox1.Items.Count - 1)
If ListBox1.Items(x) = True Then GenerateText = GenerateText & ListBox1.Items (x) & vbCrLf
Next
GenerateText = GenerateText & "" & vbCrLf
GenerateText = GenerateText & Text1.Text
End Function
-
Oct 22nd, 2002, 05:36 PM
#5
Just a note if you are adding text to a variable you can use this shortcut:
GenerateText &= Text1.Text
Instead of:
GenerateText = GenerateText & Text1.Text
-
Oct 22nd, 2002, 05:49 PM
#6
Thread Starter
New Member
hmm
ok i am slowly but surely getting it i think ...thanks for being patient...but i still get the
'Text1 is not declared'
...what am i missing? thanks a lot!
- justin
-
Oct 22nd, 2002, 05:51 PM
#7
PowerPoster
Text1 should be a textbox control on your form. If you renamed it, then you will need to change the Text1 to whatever you named it.
-
Oct 22nd, 2002, 11:13 PM
#8
Thread Starter
New Member
more fun..
once again thanks for the responses folks..you been great...another thing thats boggling my little brain..
Private Sub Button1_Click()
Dim data As String
data = GenerateText()
Clipboard.Clear()
Clipboard.SetText(data)
MsgBox("Data copied to clipboard. ", vbInformation + vbOKOnly, "Task Done")
End Sub
after the code i've pasted earlier is now straightened out..here is the following that i'm trying to get to work in vb .net that i was using in vb6. i tried to change the clipboard.clear to:
Clipboard.GetDataObject()
Clipboard.SetDataObject()
i think i'm a little screwed up still..any info would help mucho 
justin
-
Oct 22nd, 2002, 11:18 PM
#9
PowerPoster
You know that you can open a VB6 project in .Net, and the upgrade wizard will start. It will try to convert your old VB6 code to VB.Net code. Works pretty well, but it won't get everything.
-
Oct 22nd, 2002, 11:47 PM
#10
Thread Starter
New Member
hmm
i tried but i only have vb .net standard not professional so it says i'm not cool enough to use it (jk) it says my version doesn't support it.
- justin
-
Oct 23rd, 2002, 12:41 PM
#11
Thread Starter
New Member
hmmm...
any ideas? sorry to keep buggin.
justin
-
Oct 23rd, 2002, 01:08 PM
#12
In this case I don't think you need to clear the clipboard because the old value will be reset to the new one.
-
Oct 23rd, 2002, 01:11 PM
#13
PowerPoster
http://msdn.microsoft.com/library/de...albasicnet.asp
or
http://msdn.microsoft.com/library/de...eclipboard.asp
or
http://msdn.microsoft.com/library/de...mbersTopic.asp
I am not sure what your asking about the clipboard, but those three links should get you all the information you need to deal with the clipboard. If your still having problems, post the code, where the error is, what you are trying to do, and I will see if I can help you further.
-
Oct 23rd, 2002, 01:17 PM
#14
Thread Starter
New Member
hmm..
yup, i've been looking on msdn...thanks for the help and links..i'll try to get that part hammered out.
my next task is going to be pulling from a sql database on an interval and caching the db information locally in a file somehow so if network connectivity gets lost the tool will still be functional....does this sound feasable to the rest of you? like basically when i create the installer it has no content, then once you make the sql db connection for the first time it creates a local file and caches it and then checkes every 5 hours for an update or i can push them out and force updates? does this seem possibe....or am i going to have a go back to the drawing board?
thanks!
justin
-
Oct 23rd, 2002, 01:23 PM
#15
PowerPoster
It seems possible, but is the app going to be running continuously?
If not, I would just make a seperate thread to pull the data from the server, and start that thread on each startup. This way it won't affect performance of the app because it will do it in the background.
I am sure there are many, many ways to do this, and DB's really aren't my strongest of skills. I am sure someone else will have a better idea.
-
Oct 23rd, 2002, 01:28 PM
#16
Originally posted by hellswraith
Text1 should be a textbox control on your form. If you renamed it, then you will need to change the Text1 to whatever you named it.
Point of interest on that. In VB6 a textbox default name was Text1.
In .Net it is TextBox1
-
Oct 23rd, 2002, 01:28 PM
#17
Thread Starter
New Member
yes, basically what the app is going to do is be deployed to many users and there will be a back end web server with forms for me to submit the database updates with.
when i make changes i want them to eventually get out to everyone...so i want to put a time interval on it to hit the web server where the sql server resides every few hours AND have an option to force an update ...
if i did it on launch of the app that might work..but what about the force of an update? is that possible? 
- justin
-
Oct 23rd, 2002, 01:29 PM
#18
Thread Starter
New Member
cander,
thanks...sometimes i overlook really easy stuff and i'm thankful for people like you to show me the way...appreciate it.
justin
-
Oct 23rd, 2002, 03:34 PM
#19
PowerPoster
if i did it on launch of the app that might work..but what about the force of an update? is that possible?
Just have a button that updates it. Then just do the same thing you did on startup.
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
|