Download docx - programacion

Transcript

ublic Class Form1Public Function Num2Text(ByVal value As Double) As String

value = Int(value)

Select Case value

Case 1 : Num2Text = "I"

Case 2 : Num2Text = "II"

Case 3 : Num2Text = "III"

Case 4 : Num2Text = "IV"

Case 5 : Num2Text = "V"

Case 6 : Num2Text = "VI"

Case 7 : Num2Text = "VII"

Case 8 : Num2Text = "VIII"

Case 9 : Num2Text = "lX"

Case 10 : Num2Text = "X"

Case 11 : Num2Text = "XI"

Case 12 : Num2Text = "XII"

Case 13 : Num2Text = "XIII"

Case 14 : Num2Text = "XIV"

Case 15 : Num2Text = "XV"

Case Is < 20 : Num2Text = "X" & Num2Text(value - 10)

Case 20 : Num2Text = "XX"

Case Is < 30 : Num2Text = "XX" & Num2Text(value - 20)

Case 30 : Num2Text = "XXX"

Case 40 : Num2Text = "XI"

Case 50 : Num2Text = "L"

Case 60 : Num2Text = "LX"

Case 70 : Num2Text = "LXX"

Case 80 : Num2Text = "LXXX"

Case 90 : Num2Text = "XC"

Case Is < 100 : Num2Text = Num2Text(Int(value \ 10) * 10) & "" & Num2Text(value Mod 10)

Case 100 : Num2Text = "C"

Case Is < 200 : Num2Text = "C" & Num2Text(value - 100)

Case 200, 300, 400, 600, 800 : Num2Text = Num2Text(Int(value \ 100)) & "C"

Case 500 : Num2Text = "D"

Case 700 : Num2Text = "DCC"

Case 900 : Num2Text = "CM"

Case Is < 1000 : Num2Text = Num2Text(Int(value \ 100) * 100) & " " & Num2Text(value Mod 100)

Case 1000 : Num2Text = "M"

Case Is < 2000 : Num2Text = "M" & Num2Text(value Mod 1000)

Case Is < 1000000 : Num2Text = Num2Text(Int(value \ 1000)) & " M"

If value Mod 1000 Then Num2Text = Num2Text & " " & Num2Text(value Mod 1000)

End Select

If value = 1 Then

Txtmonl.Text = Num2Text

Else

txtmonl.Text = Num2Text

End If

End Function

'PROGRAMANDO EN LA ZONA DEL BUTTO EN EL EVENTOCLICK

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim sValor As String

Dim i, r As Single

sValor = txtmon.Text

txtmon.Text = Val(Replace(sValor, ",", "."))

i = Int(Val(txtmon.Text))

r = CInt((txtmon.Text - i) * 100)

Num2Text(Val(txtmon.Text))

If r > 0 Then

Txtmonl.Text = Txtmonl.Text & " CON " + Num2Text(r)

End If

txtmon.Text = Format(txtmon.Text, )

End Sub

Private Sub Igual_Click()Select Case signo 'la variable signo te dice si sumas(0) si restas(1)......Case 0Text1.Text = suma(anterior, Val(Text1.Text)) 'llamada a la funcin sumaCase 1Text1.Text = resta(anterior, Val(Text1.Text))

Case 2Text1.Text = multiplicar(anterior, Val(Text1.Text))Case 3Text1.Text = Dividir(anterior, Val(Text1.Text))End SelectEnd Sub

Private Sub Nueva_Click()Text1.Text = ""End Sub

Private Sub Operador_Click(Index As Integer)signo = Index 'si index es 0 sumas, si es 1 restas......anterior = Val(Text1.Text)Text1.Text = ""

End Sub

Private Sub Numero_Click(Index As Integer)Text1.Text = Text1.Text + Numero(Index).CaptionEnd Sub

Private Function suma(Numero As Integer, Operador As Integer) As Integersuma = Numero + OperadorEnd Function

Private Function resta(Numero As Integer, Operador As Integer) As Integerresta = Numero - OperadorEnd Function

Private Function multiplicar(Numero As Integer, Operador As Integer) As Integermultiplicar = Numero * OperadorEnd Function

Private Function Dividir(Numero As Integer, Operador As Integer) As IntegerDividir = Numero / OperadorEnd Function

Private Sub Salir_Click()Unload MeEnd Sub