Public Class Form1
Sub clear()
txtasc.Text = ""
txtasc.Focus()
cmddel.Enabled = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ascii As Int16, car As String, num As Int16
If txtasc.Text <> "" Then
If mnuasc.Checked = True Then
txtasc.MaxLength = 1
ascii = Asc(txtasc.Text)
txtasc.Text = ascii
Button1.Enabled = False
Else
If Not IsNumeric(txtasc.Text) Then
MsgBox("Char code error", MsgBoxStyle.Critical, "Error")
Call clear()
Exit Sub
End If
num = CInt(txtasc.Text)
If num > 31 And num < 255 Then
car = Chr(txtasc.Text)
txtasc.Text = car
Button1.Enabled = False
Else
MsgBox("Char code error", MsgBoxStyle.Critical, "Error")
Call clear()
Exit Sub
End If
End If
Else
txtasc.Focus()
End If
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
Private Sub cmddel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddel.Click
If txtasc.Text <> "" Then
txtasc.Text = ""
txtasc.Focus()
cmddel.Enabled = False
End If
Button1.Enabled = True
End Sub
Private Sub txtasc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtasc.TextChanged
cmddel.Enabled = True
End Sub
Private Sub EsciToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EsciToolStripMenuItem.Click
MsgBox("Programma realizzato da Albertking82", MsgBoxStyle.Information, "Creatore")
End
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
MsgBox("Programma realizzato da Albertking82", MsgBoxStyle.Information, "Creatore")
End
End Sub
Private Sub mnuchar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuchar.Click
If mnuchar.Checked = False Then
txtasc.MaxLength = 3
mnuchar.Checked = True
mnuasc.Checked = False
End If
End Sub
Private Sub mnuasc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuasc.Click
If mnuasc.Checked = False Then
txtasc.MaxLength = 1
mnuasc.Checked = True
mnuchar.Checked = False
End If
End Sub
End Class