Jump to content
worm69

como fazer sen-1, cos-1, tg-1

Recommended Posts

ribeiro55

Asen, Acos e Atan respectivamente.

Tudo na classe Math.


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
worm69

eu tenho isto

a = TextBox1.Text

        If c = 10 Then

            a = Val(TextBox1.Text)

            den = 180 / a

            TextBox1.Text = Math.Acos(Math.PI / den)

        End If

esta mal certo?

Share this post


Link to post
Share on other sites
thoga31

Asen, Acos e Atan respectivamente.

Tudo na classe Math.

Pensava que era ArcSen, ArcCos e ArcTan... Tenho de rever isso, o IntelliSense ajuda tanto que muitos códigos eu não memorizo ;)

eu tenho isto

a = TextBox1.Text

        If c = 10 Then

            a = Val(TextBox1.Text)

            den = 180 / a

            TextBox1.Text = Math.Acos(Math.PI / den)

        End If

esta mal certo?

Mas de que tipo de dados é o "a"? Ora é String ("a = TextBox_1.Text) ora é numérico (a = Val(...))? 🤔  Estás a utilizá-lo como Object?


Knowledge is free!

Share this post


Link to post
Share on other sites
worm69
Public Class Form1
    Dim a, b, c, d, den, fac As Double





    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles soma.Click
        c = 1
        a = TextBox1.Text + a
        TextBox1.Text = ""
        
    End Sub

    Private Sub igual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles igual.Click
        b = TextBox1.Text
        If c = 1 Then
            TextBox1.Text = a + b
        End If

        b = TextBox1.Text
        If c = 2 Then
            TextBox1.Text = a - b
        End If
        b = TextBox1.Text
        If c = 3 Then
            TextBox1.Text = a * b
        End If
        b = TextBox1.Text
        If c = 4 Then
            TextBox1.Text = a / b
        End If

        b = TextBox1.Text
        If c = 5 Then
            TextBox1.Text = a ^ b
        End If

        a = TextBox1.Text
        If c = 6 Then
            TextBox1.Text = a ^ 0.5
        End If

        a = TextBox1.Text
        If c = 7 Then
            a = Val(TextBox1.Text)

            den = 180 / a

            TextBox1.Text = Math.Sin(Math.PI / den)
        End If

        a = TextBox1.Text
        If c = 8 Then
            a = Val(TextBox1.Text)

            den = 180 / a

            TextBox1.Text = Math.Cos(Math.PI / den)
        End If

        a = TextBox1.Text
        If c = 9 Then
            a = Val(TextBox1.Text)

            den = 180 / a

            TextBox1.Text = Math.Tan(Math.PI / den)
        End If
        a = TextBox1.Text

        If c = 10 Then
            a = Val(TextBox1.Text)

            den = 180 / a

            TextBox1.Text = Math.Acos(Math.PI / den)
        End If



        a = 0

    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        Me.Close()
    End Sub

    Private Sub subtraçao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subtraçao.Click
        c = 2
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub produto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles produto.Click
        c = 3
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub divisao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles divisao.Click
        c = 4
        a = TextBox1.Text
        TextBox1.Text = ""


    End Sub

    Private Sub zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zero.Click


        TextBox1.Text = TextBox1.Text + "0"


    End Sub

    Private Sub um_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles um.Click
        TextBox1.Text = TextBox1.Text + "1"


    End Sub

    Private Sub dois_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dois.Click
        TextBox1.Text = TextBox1.Text + "2"

    End Sub

    Private Sub tres_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tres.Click
        TextBox1.Text = TextBox1.Text + "3"

    End Sub

    Private Sub quatro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quatro.Click
        TextBox1.Text = TextBox1.Text + "4"

    End Sub

    Private Sub cinco_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cinco.Click
        TextBox1.Text = TextBox1.Text + "5"

    End Sub

    Private Sub seis_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles seis.Click
        TextBox1.Text = TextBox1.Text + "6"

    End Sub

    Private Sub sete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sete.Click
        TextBox1.Text = TextBox1.Text + "7"

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub oito_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles oito.Click

        TextBox1.Text = TextBox1.Text + "8"

    End Sub

    Private Sub nove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nove.Click

        TextBox1.Text = TextBox1.Text + "9"

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox1.Text = ""
    End Sub

    Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click


        TextBox1.Text = TextBox1.Text + "3,14"
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = TextBox1.Text + ","
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        c = 5
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        c = 6
        TextBox1.Text = ""



    End Sub

    
    
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        c = 7
        TextBox1.Text = ""
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        c = 8
        TextBox1.Text = ""
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        c = 9
        TextBox1.Text = ""
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click


        a = TextBox1.Text

        a = Val(TextBox1.Text)

        fac = 1



        While (a <> 0)

            fac = fac * a

            a = a - 1
            TextBox1.Text = fac

        End While
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        c = 10
        TextBox1.Text = ""
    End Sub
End Class
[code]

Share this post


Link to post
Share on other sites
ribeiro55

Val não é um tipo de dados.

a é Double.

Acos/Atan/Asin precisa do valor do cosseno/tangente/seno. Para que metes o 180 e o PI ao barulho?

Penso que Acos/Atan/Asin já devolva o ângulo em graus.


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
thoga31

No teu código tens o "a" como Double e depois tens isto:

a = TextBox1.Text + a

Quando TextBox1.Text é String. Cuidado com estas conversões implícitas. ;)


Knowledge is free!

Share this post


Link to post
Share on other sites
worm69

Public Class Form1
    Dim a, b, c, d, x, fac, pi As Double





    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles soma.Click
        c = 1
        a = TextBox1.Text + a
        TextBox1.Text = ""
        
    End Sub

    Private Sub igual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles igual.Click
        If x = 1 Then
            b = TextBox1.Text
            If c = 1 Then
                TextBox1.Text = a + b
            End If

            b = TextBox1.Text
            If c = 2 Then
                TextBox1.Text = a - b
            End If
            b = TextBox1.Text
            If c = 3 Then
                TextBox1.Text = a * b
            End If
            b = TextBox1.Text
            If c = 4 Then
                TextBox1.Text = a / b
            End If

            b = TextBox1.Text
            If c = 5 Then
                TextBox1.Text = a ^ b
            End If

            a = TextBox1.Text
            If c = 6 Then
                TextBox1.Text = a ^ 0.5
            End If

            a = TextBox1.Text
            If c = 7 Then

                TextBox1.Text = Math.Sin(a)
            End If
            a = TextBox1.Text
            If c = 8 Then

                TextBox1.Text = Math.Cos(a)
            End If

            a = TextBox1.Text
            If c = 9 Then
                TextBox1.Text = Math.Tan(a)
            End If

            a = TextBox1.Text

            If c = 10 Then
                TextBox1.Text = Math.Acos(a)
            End If

            a = TextBox1.Text

            If c = 11 Then
                TextBox1.Text = Math.Asin(a)
            End If

            a = TextBox1.Text

            If c = 12 Then
                TextBox1.Text = Math.Atan(a)
            End If


            a = 0
        End If



        If x = 2 Then
            b = TextBox1.Text
            If c = 1 Then
                TextBox1.Text = a + b
            End If

            b = TextBox1.Text
            If c = 2 Then
                TextBox1.Text = a - b
            End If
            b = TextBox1.Text
            If c = 3 Then
                TextBox1.Text = a * b
            End If
            b = TextBox1.Text
            If c = 4 Then
                TextBox1.Text = a / b
            End If

            b = TextBox1.Text
            If c = 5 Then
                TextBox1.Text = a ^ b
            End If

            a = TextBox1.Text
            If c = 6 Then
                TextBox1.Text = a ^ 0.5
            End If



            pi = 3.141592654
            a = TextBox1.Text
            If c = 7 Then

                TextBox1.Text = Math.Sin(a * (pi / 180))
            End If
            a = TextBox1.Text
            If c = 8 Then

                TextBox1.Text = Math.Cos(a * (pi / 180))
            End If

            a = TextBox1.Text
            If c = 9 Then
                TextBox1.Text = Math.Tan(a * (pi / 180))
            End If

            a = TextBox1.Text

            If c = 10 Then
                TextBox1.Text = Math.Acos(a * (pi / 180))
            End If

            a = TextBox1.Text

            If c = 11 Then
                TextBox1.Text = Math.Asin(a * (pi / 180))
            End If

            a = TextBox1.Text

            If c = 12 Then
                TextBox1.Text = Math.Atan(a * (pi / 180))
            End If


            a = 0
        End If
    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        Me.Close()
    End Sub

    Private Sub subtraçao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subtraçao.Click
        c = 2
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub produto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles produto.Click
        c = 3
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub divisao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles divisao.Click
        c = 4
        a = TextBox1.Text
        TextBox1.Text = ""


    End Sub

    Private Sub zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zero.Click


        TextBox1.Text = TextBox1.Text + "0"


    End Sub

    Private Sub um_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles um.Click
        TextBox1.Text = TextBox1.Text + "1"


    End Sub

    Private Sub dois_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dois.Click
        TextBox1.Text = TextBox1.Text + "2"

    End Sub

    Private Sub tres_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tres.Click
        TextBox1.Text = TextBox1.Text + "3"

    End Sub

    Private Sub quatro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quatro.Click
        TextBox1.Text = TextBox1.Text + "4"

    End Sub

    Private Sub cinco_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cinco.Click
        TextBox1.Text = TextBox1.Text + "5"

    End Sub

    Private Sub seis_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles seis.Click
        TextBox1.Text = TextBox1.Text + "6"

    End Sub

    Private Sub sete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sete.Click
        TextBox1.Text = TextBox1.Text + "7"

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub oito_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles oito.Click

        TextBox1.Text = TextBox1.Text + "8"

    End Sub

    Private Sub nove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nove.Click

        TextBox1.Text = TextBox1.Text + "9"

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox1.Text = ""
    End Sub

    Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click


        TextBox1.Text = TextBox1.Text + "3,14"
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = TextBox1.Text + ","
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        c = 5
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        c = 6
        TextBox1.Text = ""



    End Sub

    
    
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        c = 7
        TextBox1.Text = ""
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        c = 8
        TextBox1.Text = ""
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        c = 9
        TextBox1.Text = ""
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click


        a = TextBox1.Text

        a = Val(TextBox1.Text)

        fac = 1



        While (a <> 0)

            fac = fac * a

            a = a - 1
            TextBox1.Text = fac

        End While
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        c = 10
        TextBox1.Text = ""
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        c = 11
        TextBox1.Text = ""
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        c = 12
        TextBox1.Text = ""
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        x = 1
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        x = 2
    End Sub
End Class

o meu problema é que nao consigo ter os asin, acos , atg em graus so em radianos

No teu código tens o "a" como Double e depois tens isto:

a = TextBox1.Text + a

quanto a isto tenho ke subestituir "text" por val?

:wallbash:

Share this post


Link to post
Share on other sites
thoga31

Utiliza as tags CODE e não QUOTE para o código! Para VB.NET, [ code=vbnet ][ /code ] sem os espaços.

quanto a isto tenho ke subestituir "text" por val?

:wallbash:

Ok. Ainda não tens as bases consolidadas. Vamos a isto.

Tens vários tipos de dados, e uma das infelicidades do VB.NET é ser muito permissivo nas conversões implícitas. Sim, VB lovers, eu acho uma autêntica infelicidade. :cheesygrin:

Tu tens a variável "a" como Double, e nessa linha de código estás a somar uma String (TextBox1.Text) a um Double (a) e estás a atribui-lo, por fim, numa variável Double. O que tens de fazer é um processo de conversão de String para Double, tipo isto:

a = Convert.ToDouble(TextBox1.Text) + a

Este processo é melhor do que o Val, pois é da plataforma .NET e não é um processo antigo como o Val que só existe ainda para compatibilidade. :)


Knowledge is free!

Share this post


Link to post
Share on other sites
worm69

pois mais ainda continuo com o problema dos sen-1, cos-1, tg-1 em graus.....

estou a trabalhar em vb2008 posso fazer upload se for nessessario para me ajudares

Share this post


Link to post
Share on other sites
thoga31

Confesso que entretanto me perdi nisto dos radianos e graus.

Essas funções têm input em radianos. O que pretendes exactamente?


Knowledge is free!

Share this post


Link to post
Share on other sites
worm69

que quando o radiobutton2 estiver selecionado o valor de asin, acos e atan se seja devolvido em graus.... e nao e em radianos

aqui esta o meu projecto em vb2008 se tevires tempo tenta ver isso......amanha volto a passar por aqui obrigado :cheesygrin:

http://www.megaupload.com/?d=H4O73YVH

Share this post


Link to post
Share on other sites
thoga31

Cria uma função de conversão, isto se não existir já uma (não sei se existe). Mas é um bom exercício.

Function Rad2Deg(ByVal Angulo As Double) As Double
    ' TPC  ;D
End Function

E por fim, por exemplo:

a = Rad2Deg(Math.ASin(ang))  'ang em radianos


Knowledge is free!

Share this post


Link to post
Share on other sites
ribeiro55
Sim, VB lovers, eu acho uma autêntica infelicidade. :cheesygrin:

O VB é melhor do que o que tu julgas. Liga o Option Strict na página do "My Project", e acaba-se a infelicidade :)


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
worm69

Public Class Form1
    Dim a, b, c, d, x, fac, pi As Double

    Function Rad2Deg(ByVal Angulo As Double) As Double
        ' TPC  ;D

    End Function

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles soma.Click
        c = 1
        a = Convert.ToDouble(TextBox1.Text) + a
        TextBox1.Text = ""
        
    End Sub

    Private Sub igual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles igual.Click
        If x = 1 Then
            b = TextBox1.Text
            If c = 1 Then
                TextBox1.Text = a + b
            End If

            b = TextBox1.Text
            If c = 2 Then
                TextBox1.Text = a - b
            End If
            b = TextBox1.Text
            If c = 3 Then
                TextBox1.Text = a * b
            End If
            b = TextBox1.Text
            If c = 4 Then
                TextBox1.Text = a / b
            End If

            b = TextBox1.Text
            If c = 5 Then
                TextBox1.Text = a ^ b
            End If

            a = TextBox1.Text
            If c = 6 Then
                TextBox1.Text = a ^ 0.5
            End If

            a = TextBox1.Text
            If c = 7 Then

                TextBox1.Text = Math.Sin(a)
            End If
            a = TextBox1.Text
            If c = 8 Then

                TextBox1.Text = Math.Cos(a)
            End If

            a = TextBox1.Text
            If c = 9 Then
                TextBox1.Text = Math.Tan(a)
            End If

            a = TextBox1.Text

            If c = 10 Then
                TextBox1.Text = Math.Acos(a)
            End If

            a = TextBox1.Text

            If c = 11 Then
                TextBox1.Text = Math.Asin(a)
            End If

            a = TextBox1.Text

            If c = 12 Then
                TextBox1.Text = Math.Atan(a)
            End If


            a = 0
        End If



        If x = 2 Then
            b = TextBox1.Text
            If c = 1 Then
                TextBox1.Text = a + b
            End If

            b = TextBox1.Text
            If c = 2 Then
                TextBox1.Text = a - b
            End If
            b = TextBox1.Text
            If c = 3 Then
                TextBox1.Text = a * b
            End If
            b = TextBox1.Text
            If c = 4 Then
                TextBox1.Text = a / b
            End If

            b = TextBox1.Text
            If c = 5 Then
                TextBox1.Text = a ^ b
            End If

            a = TextBox1.Text
            If c = 6 Then
                TextBox1.Text = a ^ 0.5
            End If



            pi = 3.141592654
            a = Convert.ToDouble(TextBox1.Text)
            If c = 7 Then

                TextBox1.Text = Math.Sin(a * (Math.PI / 180))
            End If
            a = Convert.ToDouble(TextBox1.Text)
            If c = 8 Then

                TextBox1.Text = Math.Cos(a * (Math.PI / 180))
            End If

            a = Convert.ToDouble(TextBox1.Text)
            If c = 9 Then
                TextBox1.Text = Math.Tan(a * (Math.PI / 180))
            End If

            a = Convert.ToDouble(TextBox1.Text)

            If c = 10 Then
                d = Math.Acos(a)
                TextBox1.Text = (d * 180) / Math.PI
            End If

            a = Convert.ToDouble(TextBox1.Text)

            If c = 11 Then
                d = Math.Asin(a)
                TextBox1.Text = (d * 180) / Math.PI
            End If

            a = Convert.ToDouble(TextBox1.Text)

            If c = 12 Then
                d = Math.Atan(a)
                TextBox1.Text = (d * 180) / Math.PI
            End If


            a = 0
        End If
    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        Me.Close()
    End Sub

    Private Sub subtraçao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles subtraçao.Click
        c = 2
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub produto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles produto.Click
        c = 3
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub divisao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles divisao.Click
        c = 4
        a = TextBox1.Text
        TextBox1.Text = ""


    End Sub

    Private Sub zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zero.Click


        TextBox1.Text = TextBox1.Text + "0"


    End Sub

    Private Sub um_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles um.Click
        TextBox1.Text = TextBox1.Text + "1"


    End Sub

    Private Sub dois_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dois.Click
        TextBox1.Text = TextBox1.Text + "2"

    End Sub

    Private Sub tres_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tres.Click
        TextBox1.Text = TextBox1.Text + "3"

    End Sub

    Private Sub quatro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quatro.Click
        TextBox1.Text = TextBox1.Text + "4"

    End Sub

    Private Sub cinco_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cinco.Click
        TextBox1.Text = TextBox1.Text + "5"

    End Sub

    Private Sub seis_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles seis.Click
        TextBox1.Text = TextBox1.Text + "6"

    End Sub

    Private Sub sete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sete.Click
        TextBox1.Text = TextBox1.Text + "7"

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub oito_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles oito.Click

        TextBox1.Text = TextBox1.Text + "8"

    End Sub

    Private Sub nove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nove.Click

        TextBox1.Text = TextBox1.Text + "9"

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox1.Text = ""
    End Sub

    Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click


        TextBox1.Text = TextBox1.Text + "3,14"
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = TextBox1.Text + ","
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        c = 5
        a = TextBox1.Text
        TextBox1.Text = ""

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        c = 6
        TextBox1.Text = ""



    End Sub

    
    
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        c = 7
        TextBox1.Text = ""
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        c = 8
        TextBox1.Text = ""
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        c = 9
        TextBox1.Text = ""
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click


        a = TextBox1.Text

        a = Val(TextBox1.Text)

        fac = 1



        While (a <> 0)

            fac = fac * a

            a = a - 1
            TextBox1.Text = fac

        End While
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        c = 10
        TextBox1.Text = ""
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        c = 11
        TextBox1.Text = ""
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        c = 12
        TextBox1.Text = ""
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        x = 1
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        x = 2
    End Sub
End Class

agora ja esta tudo a funcionar bem....mas tentei utilizar o teu concelho da funtion e nao consegui.... ajudas me?

Share this post


Link to post
Share on other sites
bioshock

O VB é melhor do que o que tu julgas. Liga o Option Strict na página do "My Project", e acaba-se a infelicidade :cheesygrin:

Ou simplesmente escrever, para ser mais fácil:

Option Strict On

Antes do:

Public Class Form1

Quanto à função, tens de a chamar de alguma forma para obteres um resultado..simples exemplo:

  Function Rad2Deg(ByVal Angulo As Double) As Double
        MsgBox(Angulo)
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Rad2Deg(13)
    End Sub

Share this post


Link to post
Share on other sites
thoga31

O VB é melhor do que o que tu julgas. Liga o Option Strict na página do "My Project", e acaba-se a infelicidade :cheesygrin:

Oh, eu conheço bem essa opção. Eu tenho-a desligada. Como programador de Pascal, estou bastante habituado a fazer as devidas conversões. Por isso não gosto de conversões implícitas, excepto no caso de uma variável Object que eu necessite e que tem as suas vantagens maravilhosas. :)


Knowledge is free!

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

×
×
  • Create New...

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.