0% found this document useful (0 votes)
67 views12 pages

Guia Ejercicio 1: Private Sub Resultado - Click Resultado - Caption ( (Val (Dato1.text) Val (Dato2.text) ) + 3) 5 End Sub

The document contains summaries for 10 coding exercises. Each exercise demonstrates how to perform different operations like calculations, bitwise operations, conversions between decimal and binary. Code snippets are provided to show how to implement the logic for tasks like setting labels, timers, buttons, and performing bit operations.

Uploaded by

lanuse
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views12 pages

Guia Ejercicio 1: Private Sub Resultado - Click Resultado - Caption ( (Val (Dato1.text) Val (Dato2.text) ) + 3) 5 End Sub

The document contains summaries for 10 coding exercises. Each exercise demonstrates how to perform different operations like calculations, bitwise operations, conversions between decimal and binary. Code snippets are provided to show how to implement the logic for tasks like setting labels, timers, buttons, and performing bit operations.

Uploaded by

lanuse
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Guia Ejercicio 1

Private Sub resultado_Click() resultado.Caption = ((Val(dato1.Text) * Val(dato2.Text)) + 3) * 5 End Sub

Guia ejercicio 2

Private Sub Command1_Click() Command1.Caption = Val(dato.Text) Or 195 End Sub

Guia ejercicio 3

Public ban As Integer Private Sub Timer1_Timer() ban = ban + 1 If ban = 1 Then Label1.Caption = 5 End If If ban = 2 Then Label1.Caption = 8 End If If ban = 3 Then Label1.Caption = 9 End If

If ban = 4 Then Label1.Caption = 10 ban = 0 End If End Sub

Guia ejercicio 4

Public res As Byte Private Sub Timer1_Timer() res = a.Value And b.Value And c.Value res = negador(res) z.Value = res Or (c.Value And d.Value) End Sub Function negador(res As Byte) As Byte If res = 0 Then negador = 1 Else negador = 0 End If

End Function

Guia ejercicio 5

Public dato As Integer, bit As Byte 'mascaras' Private Sub Command1_Click() dato = Val(Text1.Text) bit = Val(Text2.Text) Command1.Caption = bsf(dato, bit) End Sub

Private Sub Command2_Click() dato = Val(Text1.Text) bit = Val(Text2.Text) Command2.Caption = bcf(dato, bit) End Sub

Private Sub Command3_Click() dato = Val(Text1.Text)

bit = Val(Text2.Text) Command3.Caption = compb(dato, bit) End Sub

Function bsf(dato As Integer, bit As Byte) As Integer bsf = dato Or (2 ^ bit) End Function

Function bcf(dato As Integer, bit As Byte) As Integer bcf = dato And Not (2 ^ bit) End Function

Function compb(dato As Integer, bit As Byte) As Integer compb = dato Xor (2 ^ bit) End Function

Guia ejercicio 6

Dim dato As Byte, pri As Byte, seg As Byte Private Sub Command2_Click() dato = Text1.Text pri = dato And &HF pri = pri * 16 seg = dato And &HF0 seg = Int(seg / 16) Text1.Text = pri Or seg End Sub

Guia ejercicio 7

Public dato As Integer, bit As Byte, res As Integer, res2 As Integer, res3 As Integer, resultado As Byte 'mascaras' Private Sub Command1_Click() dato = Val(Text1.Text) bit = Val(Text2.Text) res = bsf(dato, bit) res2 = bcf(dato, bit) res3 = compb(dato, bit) resultado = btf(res, res2, res3) Command1.Caption = resultado End Sub

Function bsf(dato As Integer, bit As Byte) As Integer bsf = dato Or (2 ^ bit) End Function

Function bcf(dato As Integer, bit As Byte) As Integer bcf = dato And Not (2 ^ bit) End Function

Function compb(dato As Integer, bit As Byte) As Integer compb = dato Xor (2 ^ bit) End Function

Function btf(res As Integer, res2 As Integer, res3 As Integer) As Byte If res = res3 Then btf = 0 End If If res2 = res3 Then btf = 1 End If End Function

Guia ejercicio 8

Public va As Byte, vb As Byte Private Sub Timer1_Timer() q.Value = (s.Value And negador(r.Value)) Or (negador(r.Value) And q.Value) End Sub

Function negador(a As Byte) As Byte If a = 0 Then negador = 1 Else negador = 0 End If End Function

Guia ejercicio 9

Public P3 As Byte Public P4 As Byte Public RESULTADO As Byte Private Sub Command1_Click() P4 = (d.Value And c.Value) Or (d.Value And b.Value) P3 = d.Value And Not c.Value And Not b.Value P2 = (Not d.Value And c.Value) Or (c.Value And b.Value) P1 = (Not d.Value And b.Value) Or (d.Value And c.Value And Not b.Value) P0 = a.Value RESULTADO = (P3 * 2 ^ 3) + (P2 * 2 ^ 2) + (P1 * 2 ^ 1) + (P0 * 2 ^ 0) Text2.Text = RESULTADO Text3.Text = P4 * 2 ^ 0 End Sub

Guia ejercicio 10

Private Sub Command1_Click() UNIDADES = Text1.Text CENTENAS = 0 A: DECENAS = 0 B: UNIDADES = UNIDADES - 10 If UNIDADES < 0 Then UNIDADES = UNIDADES + 10 GoTo FIN End If If UNIDADES < 10 Then DECENAS = DECENAS + 1 GoTo FIN Else: DECENAS = DECENAS + 1 If DECENAS = 10 Then CENTENAS = CENTENAS + 1

GoTo A Else: GoTo B End If End If FIN: Text2.Text = UNIDADES Text3.Text = DECENAS Text4.Text = CENTENAS End Sub

You might also like