You are on page 1of 3

Public Class Form1

Dim i, s, k As Integer
Dim b, estrai As String
Dim v(0 To 11) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
b = InputBox("inserisci byte")
For i = 1 To 12
If (i <> 1) And (i <> 2) And (i <> 4) And (i <> 8) Then
estrai = Mid(b, i, 1)
v(i - 1) = Val(estrai)
End If
Next
S = v(2) + v(4) + v(6) + v(8) + v(10)
If s Mod 2 <> 0 Then
v(0) = 1
Else
v(0) = 0
End If
s = v(2) + v(5) + v(6) + v(9) + v(10)
If s Mod 2 <> 0 Then
v(0) = 1
Else
v(0) = 0
End If
s = v(4) + v(5) + v(6) + v(11)
If s Mod 2 <> 0 Then
v(0) = 1
Else
v(0) = 0
End If
s = v(8) + v(9) + v(10) + v(11)
If s Mod 2 <> 0 Then
v(0) = 1
Else
v(0) = 0
End If

BIT 1
If v(i)mod2 <> 0 then
for i = 0 to 11
if v(i)= 1 then
c = c + 1
end if
next
if c mod 2 <> 0 then
k = k + 1
if v(1)=0 then
v(1) = 1
else
v(1) = 0
end if
end if
end if
c=0

BIT 2

if v(3) = 1 then
c = c+ 1
end if
if v(6) = 1 then
c = c+ 1
end if
if v(7) = 1 then
c = c + 1
end if
if v(10) = 1
c = c + 1
end if
if v(11) = 1 then
c = c + 1
end if
if c mod 2 <> 0 then
k = k + 2
if v(2)= 0 then
v(2) = 1
else
v(2) = 0
end if
end if
c = 0

BIT 4

for i=4 to 7
if v(i)=1 then
c = c + 1
end if
next
if v(12) = 1 then
c = c+ 1
end if
if c mod 2 <> 0 then
k = k + 4
if v(4) =0 then
v(4)=1
else
v(4) = 0
end if
c=0

BIT 8

for i = 8 to 12
if v(i)= 1 then
c = c + 1
end if
if c mod 2 <> 0 then
k = k + 8
if v(8) = 1 then
v(8) = 0

else

v(8) = 0

end if

end if
next

VISUALIZZAZIONE
for i = 1 to 12
t1.text = t1.text & v(i)
next
msgbox("l'errore era in posizione:" & k)