|
Ok, ive sorted this:
Dim c1 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter1.Text = c1.ToString()
Dim c2 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter2.Text = c2.ToString()
Dim c3 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter3.Text = c3.ToString()
Dim c4 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter4.Text = c4.ToString()
Dim c5 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter5.Text = c5.ToString()
Dim c6 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter6.Text = c6.ToString()
Dim c7 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter7.Text = c7.ToString()
Dim c8 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter8.Text = c8.ToString()
Dim c9 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter9.Text = c9.ToString()
Dim c10 As Char = Convert.ToChar(rnd.Next(97, 122)) : lblLetter10.Text = c10.ToString()
Is there anyway to put this in a loop so it doesnt take up so many lines of code, i know im just being pedantic, just thought i would check!
|
|
|
|
|
|
Gotcha! Cheers.
Just final question, can you explain exactly what this line does, is it that if lblLetter is not empy and also has a name similar to lblLetter then...???:
If lblLetter IsNot Nothing AndAlso lblLetter.Name Like pattern Then
|
|
|
|
|
Actually it wasn't necessary to change the variable 'lbl' to lblLetter. What the function does is loops through every control on your form or whatever parent control you passed in. Every control weather it's a button, or textbox, or label inherits from the control class. TryCast attempts to convert the control to a label. If this succeeds then lbl will contain a reference to a label that's on your form. However, if the control is a button or some other control that isn't a label the cast will fail and nothing will be returned. So we need to check to make sure 'lbl' isn't nothing. The function accepts a pattern so you can limit which labels get random letters, otherwise all labels on the form would get a random letter which may not be desirable. So the second part of the if statement checks to see that the name of the label matches a given patter. In your case you've named your labels that get random letters as lblLetter1, lblLetter2 and so on. So you would pass in the pattern lblLetter*. Simply put with that pattern any label with a name that begins with lblLetter will get a random letter. Hope that clears that line up.
|
|
|
|
|
Hi there,
I was wondering if it is possible to alter the display memory and display other things , like i capture the desktop, enlarge it *4 and then display it as the normal desktop woud be displayed
on the screen , no forms no programs just the dektop (the program running behind the scenes capturing the real desktop on a time based event) and the mouse
So i can capture the screen and i'm able to show it in a picturebox , so it like i have the desktop and a form with a part of it.
my question was if it was possible and how
Kind regards
|
|
|
|
|
An article was recently submitted that does this, it's claim to fame is that it doens't use p/invoke. Generally, you'd pinvoke some Windows APIs to capture the screen. Search the articles on the site, there's at least one or two that do this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I need some advice:
I have a listview which has check boxes and controls the checked items in a different listview. For example, if ProductA is checked in ListViewA then ListViewB will automatically check the items which relate to ProductA. My question is:
How can I find the appropriate items in ListViewB and set their state to checked?
My second question is:
Is it possible to disable some of the checkboxes in the listview control and leave the other ones enabled so users can check and uncheck them?
Thanks b4 hand,
Yoshimitsu
|
|
|
|
|
Well, how are you getting these items in the first place. From a database? The items in ListViewB would need some sort of way to distinguish them. This way you could filter the names on whatever the item happens to be. For instance Male and Female names might be in ListViewA. When you select Male you need to look at the items in ListViewB and determine if it's a male name. How you do this would be dependent on your situation. So maybe you could describe where this data is coming from and how it's set up.
I don't think it's possible to disable some checkboxes but not all. However, if this is what you want you might be able to fake it. Although, it sounds like only displaying the appropiate items is a more user friendly approach. To prevent an item from changing you could use this code.
Private Sub ListView1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck
e.NewValue = e.CurrentValue
End Sub
This will prevent all items from changing so in order to use this you'll need to keep track of which items should be allowed to change and prevent just the ones that aren't in that list to change.
|
|
|
|
|
Thanks TwoFaced,
Here is what's happening:
The user enters a name through a textbox for example Breakfast and then selects a bunch of food items from a listview with checkboxes. Then the user can press save and make another record, for example, for lunch and so on. Each customer can have many meals, and each meal has many items. when the user clicks save I push the record into an arraylist and when the user presses finish I send the records from the arraylist to the database and the form closes.
In the parent form there is listview so when user clicks on Breakfast then I have to get all the selected items and find those items in ListViewB and check them accordingly.
I managed to do it by looping through the Arraylist, and comparing each items string to each item's string in ListViewB, if match then I check them.
However, I don't think this a good approach, right?
I hope this makes things clear.
Yoshimitsu
|
|
|
|
|
I think things are a little clearer. I've now got a general picture of your scenerio. For all I know there is a brilliant solution to your overall problem, but I don't have one. However, I'll give you what I've got. You can add items to the listview with a key and then access that item using that key. Now from what I understand you've got food items in listviewB. So the name of the item would be the key. The user selects say 'Breakfast' from ListViewA. You then get the food items the user wants for breakfast and store that in an arraylist. You could then access each item in ListViewB directly by using the items name because you used the name as the key. Hopefully some code will make this clearer. Here is a little example which shows what I'm talking about.
'---Add items with keys---
With ListView1.Items
.Add("Steak", "Steak", "")
.Add("Apple", "Apple", "")
.Add("Rice", "Rice", "")
End With
'---Uncheck previous items---
For i As Integer = ListView1.CheckedItems.Count - 1 To 0 Step -1
ListView1.CheckedItems(i).Checked = False
Next
Dim itemsToSelect As String() = {"Steak", "Rice"}
For Each item As String In itemsToSelect
ListView1.Items(item).Checked = True
Next
One thing I don't understand is why does ListViewB have check boxes and why are you checking the items instead of filling ListViewB with just the items the user had selected for 'Breakfast'? It seems to me this would be a nicer approach but maybe there is more to this that I don't understand yet. Either way the code I posted should give you an idea of how to more directly access each item instead of looping through all the items in the list.
|
|
|
|
|
Hello !
I'm currently quite a problem I can't figure out.
I have a VB6 ActiveX that does numerous actions on an Oracle database. This component calls another one that sends the queries to the database.
It uses MTS transactions with GetObjectContext.
For years it has worked perfectly !
Since couple of months I'm having the weirdest problems with it.
The most significant is a delay whenever I insert or update records in the database.
Sometimes it takes 10~15 seconds before the data is actually in the database.
Sadly there's no way I can test that on my machine since the problem is random !
Out of all actions it performs, a mere 10% comes out bad and I have to manually correct them.
The database component is called by many other applications on the same server and works just fine. No other applications have shown anything like this problem.
My component uses just the same settings as the others one.
The component uses very few CPU and through the Component Services mmc I can see it runs without delay but the data it's written is magically delayed for whatever reason...
The server is a Windows 2003 on which we later installed SP1.
As I'm running out of ideas to try to solve it, I'm about to rewrite part of it unless some clever member here would know what it's happening !
Thanks in advance !!
|
|
|
|
|
i make a project... Now ! How can i make an installable file...? or Setup.exe file of my project
Your Good Thinker
|
|
|
|
|
goto menu debug
Publish
Set program to be installed from the setup path(installs the pre-requists first).
in a developed project its better to make setup project to have more options.
A.E.K
|
|
|
|
|
Which VB version you have? 2003 or 2005, express or studio,....
|
|
|
|
|
Thanks for reply dear i am using VB.NET 2005
Feroze
|
|
|
|
|
then if you have vb.net 2005 express you can publish as amir e sad... or if you have vb.net 2005 studio, architect or team edition whatever then you can sett up your setup settings as you wish an you can fully costumize it as you wish! Well hope i helped u... and sorry on bad English i am from Croatia. Enjoy!
|
|
|
|
|
i make a project... Now ! How can i make an installable file...?
Your Good Thinker
|
|
|
|
|
There are a number of articles on this topic. Such as this one.[^] You should search for the key words "Deployment" and "Setup project" for more information.
Hope this helps.
|
|
|
|
|
I have never used XML in windows application vb.net. I want to create if doesnt exist an xml file then be able to add nodes to it and finally search for a certain node name/id.
Can any one provide me with an answer or link to a usefull web site cause i googled a little and didnt find any thing helpfull
Thanks
|
|
|
|
|
XmlDocument is the class you need, and it impliments what's called the DOM ( document object model ). This is a standard API, so you can search for help on it's methods, such as selectSingleNode, and find lots of help. XPath is the language you use to find nodes, heaps of stuff on the web about this also.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have created my application and want it to look good. What I have is a screensaver I want to play first for 10 seconds when program starts then "Login form" will load. How would you do this? Here is what i want to happen:
You click on "Program.exe" the screensaver loads in fullscreen and plays for 10 seconds. It closes and "Login Form" loads.
Using VB.net 2005
In the end we're all just the same
|
|
|
|
|
you can make a form with formborderstyle=none and set the background in the way you want.
add a timer to your source code and set its interval= 10000 and enabled = true
add another form for your login
add code below in the timer tick sub
dim Mylogin as new frmlogin
hide
mylogin.show
timer1.enabled=false
if this can not solve your problems please describe that what is your exact problem
A.E.K
|
|
|
|
|
When im in debugging mode - and let say that im watching a object. to the left of the objects name in the watch window is a (+) meaning i can drill down. but when i click on it it simply disapears without drilling down. few weks ago my watch window was working ok - meaning i could drill down an see the properties/methods of the object i as watching. do you think there i a setting i might have switched off?
ONeil
|
|
|
|
|
i want to create conaction Between web cam and PictureBox
Want an example thnx
Ahmed El-Badry
|
|
|
|
|
You need DirectShow, search the site, there are many examples to download.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|