VB Question

Soldato
Joined
30 Dec 2004
Posts
3,340
Location
London
Hey all,

Just wanted to ask, in VB, I am trying to generate a set of buttons which when clicked in a random order will have the values inside the buttons stored as variables.

How would I go about representing those variables in the order that they were clicked in?

Wondered if anyone could hint me as to how I'd go about doing it.


Thanks
 
If I click a button, is there anyway to use OR? (not working for me at the moment)

So for example,
Label1 = But1 or But2 or But3

meaning that if I select But3 it will insert it into label1, if I select But1 it will insert it... and so on?
 
Sorry, will explain.

3 Buttons have numbers in them.

I want to be able to click button1, button2, and button3 in any order.

The order that I click them in, I want to be displayed in labels.

So if I click button3, I want the value from button3 to go into label1 (first button clicked). If I then click button1 I want the value to go into label2 (Second button clicked), and so on.

Does that make sense??

The value in button1, button2 and button3 are not constants, they are variables so i can't put a set value anywhere.
 
Last edited:
dasyad, it doesn't appear to be recognising the Private Void line you have written.

You sure this will work with numbers that are varying?

Not that advanced at VB...


I'm still not sure why it can't work by setting each label equal to all 3 buttons, and they then change depending on what one you click.

So, label1 = But1 OR But2 or But3

Meaning if I click But3, the value for But3, will be inserted into label1...then if I click but1, the value for but1 will be inserted into label1.....??
 
Last edited:
Thanks for the help guys.

@Craig87; It does... but all it seems to do is put But1 into Label1, But2 into Label2 and so on. It doesn't do it from which I pick first. I.e; if i click on the third button, it fills the Label1 with the value from But1.
 
Rather than make another thread, thought I'd put it in here.

Ok so I've now made 2 arrays.

For example;
Array One has 3, 2, 1
Array Two has 1, 2, 3

I want to be able to sort Array One in Ascending Order.

Then say "If Array One = Array Two" MessageBox.Show("Well Done").

and if not equal, MessageBox.Show("Have another go").

-

Problem I am coming across is I am coming across is that Array One will have the numbers mixed up. I'm trying to use the Array.Sort on the entire array.

I'm trying to put, for example, SortedNumbers = Array.Sort(array1)

But it gives the error "expression does not produce a value".

Just wondered if anyone knows how I go about doing this?
 
That's because Array.Sort() doesn't return anything. Its a static member.

Array.Sort(array1);

is all u need. "array1" will be sorted.

Yup, but how can I then compare the sorted array with the unsorted array?

I can't compare array1 with array2 because the array1 will be unsorted won't it? unless when you do the sort it applies it to the whole array 1?

Is that what you mean?
 
Ok, and its appearing to compare two arrays I must use the
If array1 Is array2 Then MessageBox.Show("100%") Else Messagebox.Show("Have another go").

Only problem is if I arrange the numbers into ascending order (array2) and compared with the ascending order (array1) I keep getting the "have another go" rather than "100%".
 
Back
Top Bottom