Precedente :: Successivo |
Autore |
Messaggio |
Merix98 Mortale pio
Registrato: 16/02/13 14:19 Messaggi: 25
|
Inviato: 26 Mar 2013 16:56 Oggetto: Numero random in VB??? |
|
|
Salve a tutti, devo assegnare ad un label un numero a caso naturale fra 0 e un numero contenuto in una textbox. Come faccio???? ho già provato di tutto e non ci riesco.
Grazie |
|
Top |
|
|
GrayWolf Dio maturo
Registrato: 03/07/05 16:24 Messaggi: 2325 Residenza: ... come frontiera i confini del mondo...
|
Inviato: 26 Mar 2013 22:31 Oggetto: |
|
|
salva il seguente in un file con estensione frm
Codice: |
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 5520
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 5520
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Height = 375
Left = 105
TabIndex = 2
Top = 1155
Width = 1665
End
Begin VB.TextBox Text1
Height = 300
Left = 120
TabIndex = 0
Text = "20"
Top = 165
Width = 1635
End
Begin VB.Label Label1
Height = 285
Left = 135
TabIndex = 1
Top = 660
Width = 1665
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Label1 = Int((CInt(Text1) * Rnd) + 1)
End Sub
|
Inseriscilo in un progetto e prova
NOTE:
non c'è il controllo per textbox vuoto o non numerico
se vuoi che sia incluso anche lo zero:
Codice: |
Label1 = Int((CInt(Text1) * Rnd))
|
|
|
Top |
|
|
|