:

:

. . . .

3

:

:

- 2009-


UmnDelDouble.

 


Option Explicit

Public sel As Integer

Public i, x, j, x0 As Double

Public c As Integer

Private Sub Command1_Click()

fir.Text = ""

sec.Text = ""

res.Text = ""

x = 0

j = 0

x0 = 0

i = 0

End Sub

Private Sub ext_Click()

End

End Sub


Private Sub fir_Change()

If val(fir.Text) = 0 Or val(fir.Text) = 1 Then

lb1.Caption = fir.Text

Exit Sub

Else

i = (Len(fir.Text))

x = 0

j = 0

Do

x = x + (val(Mid(fir.Text, i, 1)) * (2 ^ j))

i = i - 1

j = j + 1

Loop Until i = 0

lb1.Caption = x

End If

End Sub

: 12332131


.

Private Sub fir_GotFocus()

sel = 1

End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

On Error GoTo err:

If (KeyCode = vbKeyBack) Then

Select Case sel

Case 1

fir.Text = Left(fir.Text, Len(fir.Text) - 1)

Case 2

sec.Text = Left(sec.Text, Len(sec.Text) - 1)

End Select

Else

End If

Exit Sub

err:

Beep

End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)

Dim val As String

val = Chr(KeyAscii)

If (val >= "0") And (val <= "9") Then

If sel = 1 Then

Select Case val

Case "0"

fir.Text = fir.Text & "0"

Case "1"

fir.Text = fir.Text & "1"

End Select

ElseIf sel = 2 Then

Select Case val

Case "0"

sec.Text = sec.Text & "0"

Case "1"

sec.Text = sec.Text & "1"

End Select

Else

End If

Else

End If

End Sub

Private Sub Form_Load()

umn.Value = True

c = 1

End Sub

: 12332131


.

Private Sub res_Change()

If val(res.Text) = 0 Or val(res.Text) = 1 Then

lb3.Caption = res.Text

Exit Sub

Else

i = (Len(res.Text))

x = 0

j = 0

Do

x = x + (val(Mid(res.Text, i, 1)) * (2 ^ j))

i = i - 1

j = j + 1

Loop Until i = 0

lb3.Caption = x

End If

End Sub

Private Sub run_Click() '

Dim d(90) As Double

If fir.Text = "" Or sec.Text = "" Then

MsgBox "Incorrect input. Please input numbers again", , "=VaMp1r3="

Exit Sub

ElseIf val(lb2.Caption) = 0 Or val(lb1.Caption) = 0 Then

MsgBox "Incorrect input. Please input numbers again", , "=VaMp1r3="

Call Command1_Click

Exit Sub

ElseIf val(lb2.Caption) = 0 And val(lb1.Caption) = 0 Then

MsgBox "Incorrect input. Please input numbers again", , "=VaMp1r3="

Call Command1_Click

Exit Sub

Else

Select Case umn.Value

Case True

x0 = ((CDbl(lb1.Caption)) * (CDbl(lb2.Caption)))

x = 0

c = 1

Do

d(c) = x0 Mod 2

x = Round((CDbl(x0) / 2) - 0.3, 0)

c = c + 1

x0 = x

Loop Until x = 1

d(c) = x

res.Text = ""

Do

res.Text = res.Text & d(c)

c = c - 1

Loop Until c = 0

Case False

If val(lb2.Caption) > val(lb1.Caption) Then

MsgBox "Incorrect Input. Please input numbers again.", , "=VaMP1r3="

Exit Sub

Else

x0 = val(((CDbl(lb1.Caption)) / (CDbl(lb2.Caption))))

x = 0

c = 1

Do

If x0 = 0 Then Exit Do

d(c) = x0 Mod 2

x = Round((CDbl(x0) / 2) - 0.3, 0)

c = c + 1

x0 = x

Loop Until x = 1

d(c) = x

res.Text = ""

Do

res.Text = res.Text & d(c)

c = c - 1

Loop Until c = 0

End If

End Select

End If

End Sub

: 12332131


.


Private Sub sec_Change()

If val(sec.Text) = 0 Or val(sec.Text) = 1 Then

lb2.Caption = sec.Text

Exit Sub

Else

i = (Len(sec.Text))

x = 0

j = 0

Do

x = x + (val(Mid(sec.Text, i, 1)) * (2 ^ j))

i = i - 1

j = j + 1

Loop Until i = 0

lb2.Caption = x

End If

End Sub

Private Sub sec_GotFocus()

sel = 2

End Sub





2010