PDA

View Full Version : VB.net help if can.


Manta
13 Apr 2007, 12:10
Ohio all, those that knows VB.net, there is this Code, Random.but i have no Clue how to use it.

I tried everything but i get a constant value...

wat i want 4 example is.

Label1.text = "random number from 1-20" or something.
Can any one help me with the code and how it must look like or something?


Second, im using VB.net 2k3, now the other prob i have is:

When i Put a PictureBox1 thats Blue on a Black Background Form. and i insert a PictureBox2 that is transparent ontop of the Picturebox1 then the picturebox1's blue colour doesnt show, only the Form BG Colour (Black) so it cuts out the picture, is there a way i can change it to overlap (if you know what i meen?)

Ill apprisiate any help. Manta

I wont bother with Idiot replies.

cYan1D3
13 Apr 2007, 12:47
I never used VB but I used c++, visual age for java and Java. There should be a random function in the library.

I found something

Label1.text = Math.floor((20 - 0 + 1) * Rnd() + 0) this should get you a random
number between 0 - 20.

If it doesn't work just pwn me again :P
I got the info on http://msconline.maconstate.edu/tutorials/VBNET/VBNET01/vbnet01-06.aspx


About the picture box, I don't know never used VB.net but I suggest you get a VB tutorial it always helps.

peace

Zelphar
13 Apr 2007, 13:00
Rather use the Random class. It's much more flexible, as far as specifying what numbers you get goes. In your case (1 to 20), you'd want something similar to:

Dim foo As New Random
Label1.Text = foo.Next(1, 20).ToString()As for the picture box problem, in short, you can't. This is because .NET (And most windowing systems in general) doesn't support real transparency. When you set a control's background colour to transparent, all that happens is, instead of painting that area itself, the control asks its parent to do the painting. This is why you see the form's background instead of the first picture box (The form is the parent for both picture boxes).

Manta
13 Apr 2007, 13:01
cYan1D3 (http://www.unreal.co.za/forums/member.php?u=494) thanks for the efford, altho thecode isnt so affective, its a set value it runs each time i strat the program.

Zelphar (http://www.unreal.co.za/forums/member.php?u=526) thanks for creating a new account just to help me, apprisiate it lots! the Code Works.

So the Picture box thing is a no go,, this Sucks. but thaks!

Manta ows you lots!

J1nX
13 Apr 2007, 16:46
Manta owes everyone a lot (except me) - he usually repays in blow jobs on his street corner...