Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

axcs

Variáveis

Recommended Posts

axcs

Ola sou novo no visual basic, tou a programar no visual studio em vb . e tenho uma função:

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
        Dim dd As Integer
        Static x As Decimal = 1
        dd = txt1.Text
        If Not dd <= 4 And dd >= 1 Then
            lb3.Text = "Destino incorrecto"
            lb3.Visible = True
            dd = 0
            txt1.Clear()
            txt1.Focus()
        End If
        If dd = 1 Then

........

......

e outra função logo abaixo:

Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
        lb3.Text = x
    End Sub

A pergunta é como é que passo a variavel "x" da função de cima para a função de baixo?, se declarar uma nova aqui nesta função perco o valor que obtive em cima. e se não declarar agora a variável "x" dá erro AJUDA PF

Share this post


Link to post
Share on other sites
ribeiro55

Declara-a Private ou Public fora do sub Btn1_Click


Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.