Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Codici - decimalebinario.vb

decimalebinario.vb

Caricato da:
Scarica il programma completo

  1. Imports System
  2. Imports System.Collections
  3. Imports Microsoft.VisualBasic
  4.  
  5. Public Class decimalebinario
  6.     Inherits System.Windows.Forms.Form
  7.     Dim a As New ArrayList
  8.     Dim r As New ArrayList
  9.  
  10. #Region " Codice generato da Progettazione Windows Form "
  11.  
  12.     Public Sub New()
  13.         MyBase.New()
  14.  
  15.         'Chiamata richiesta da Progettazione Windows Form.
  16.         InitializeComponent()
  17.  
  18.         'Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent()
  19.  
  20.     End Sub
  21.  
  22.     'Form esegue l'override del metodo Dispose per pulire l'elenco dei componenti.
  23.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  24.         If disposing Then
  25.             If Not (components Is Nothing) Then
  26.                 components.Dispose()
  27.             End If
  28.         End If
  29.         MyBase.Dispose(disposing)
  30.     End Sub
  31.  
  32.     'Richiesto da Progettazione Windows Form
  33.     Private components As System.ComponentModel.IContainer
  34.  
  35.     'NOTA: la procedura che segue è richiesta da Progettazione Windows Form.
  36.     'Può essere modificata in Progettazione Windows Form.  
  37.     'Non modificarla nell'editor del codice.
  38.     Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
  39.     Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
  40.     Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
  41.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  42.         Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(decimalebinario))
  43.         Me.TextBox1 = New System.Windows.Forms.TextBox
  44.         Me.TextBox2 = New System.Windows.Forms.TextBox
  45.         Me.TextBox3 = New System.Windows.Forms.TextBox
  46.         Me.SuspendLayout()
  47.         '
  48.         'TextBox1
  49.         '
  50.         Me.TextBox1.BackColor = System.Drawing.Color.White
  51.         Me.TextBox1.Location = New System.Drawing.Point(8, 8)
  52.         Me.TextBox1.MaxLength = 1
  53.         Me.TextBox1.Name = "TextBox1"
  54.         Me.TextBox1.Size = New System.Drawing.Size(24, 20)
  55.         Me.TextBox1.TabIndex = 0
  56.         Me.TextBox1.Text = ""
  57.         Me.TextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  58.         '
  59.         'TextBox2
  60.         '
  61.         Me.TextBox2.BackColor = System.Drawing.Color.White
  62.         Me.TextBox2.Location = New System.Drawing.Point(152, 32)
  63.         Me.TextBox2.Name = "TextBox2"
  64.         Me.TextBox2.ReadOnly = True
  65.         Me.TextBox2.Size = New System.Drawing.Size(64, 20)
  66.         Me.TextBox2.TabIndex = 1
  67.         Me.TextBox2.Text = ""
  68.         '
  69.         'TextBox3
  70.         '
  71.         Me.TextBox3.AutoSize = False
  72.         Me.TextBox3.BackColor = System.Drawing.Color.White
  73.         Me.TextBox3.Location = New System.Drawing.Point(40, 8)
  74.         Me.TextBox3.MaxLength = 1
  75.         Me.TextBox3.Name = "TextBox3"
  76.         Me.TextBox3.ReadOnly = True
  77.         Me.TextBox3.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal
  78.         Me.TextBox3.Size = New System.Drawing.Size(320, 20)
  79.         Me.TextBox3.TabIndex = 3
  80.         Me.TextBox3.Text = ""
  81.         '
  82.         'decimalebinario
  83.         '
  84.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  85.         Me.ClientSize = New System.Drawing.Size(366, 60)
  86.         Me.Controls.Add(Me.TextBox3)
  87.         Me.Controls.Add(Me.TextBox2)
  88.         Me.Controls.Add(Me.TextBox1)
  89.         Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
  90.         Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
  91.         Me.MaximizeBox = False
  92.         Me.Name = "decimalebinario"
  93.         Me.ShowInTaskbar = False
  94.         Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  95.         Me.Text = "Da Binario a Decimale"
  96.         Me.ResumeLayout(False)
  97.  
  98.     End Sub
  99.  
  100. #End Region
  101.  
  102.     Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
  103.         Select Case TextBox1.Text
  104.             Case "0"
  105.                 GoTo casa
  106.             Case "1"
  107.                 GoTo casa
  108.             Case Else
  109.                 MsgBox("Inserire solo 0 oppure 1!", MsgBoxStyle.Critical, Me.Text)
  110.                 a.Clear()
  111.                 r.Clear()
  112.                 TextBox2.Clear()
  113.                 TextBox3.Clear()
  114.         End Select
  115.         Exit Sub
  116. casa:
  117.         a.Add(TextBox1.Text)
  118.         TextBox3.Text = TextBox3.Text & TextBox1.Text
  119.         TextBox1.SelectAll()
  120.  
  121.         Dim f As Integer
  122.         For f = 0 To a.Count - 1
  123.             r.Add(TextBox2.Text = a.Item(f) * (2 ^ f))
  124.         Next f
  125.         Dim t As Integer
  126.         For t = 0 To r.Count - 1
  127.             TextBox2.Text = r.Item(t) + r.Item(t + 1)
  128.         Next t
  129.     End Sub
  130.  
  131.     Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  132.         If e.KeyChar = Microsoft.VisualBasic.ChrW(27) = True Then Me.Close()
  133.     End Sub
  134.  
  135.     Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
  136.         If e.KeyChar = Microsoft.VisualBasic.ChrW(27) = True Then Me.Close()
  137.     End Sub
  138.  
  139.     Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
  140.         If e.KeyChar = Microsoft.VisualBasic.ChrW(27) = True Then Me.Close()
  141.     End Sub
  142.  
  143.     Private Sub Form10_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
  144.         If e.KeyChar = Microsoft.VisualBasic.ChrW(27) = True Then Me.Close()
  145.     End Sub
  146. End Class