🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.lang.visualbasic
Article #1205

Re: _LostFocus + .SetFocus

#1205
From: Terushi Arakawa
Date: Thu, 16 Oct 1997 00:00
156 lines
4618 bytes
$B9S@n(B@TSN BBS$B$G$9!#(B

KOKUBUN shige. (kokubun@ffc.co.jp) wrote:
> VB4.0 $B$r;HMQ$7$F$$$^$9!#(B
> Text_LostFocus()$B%$%Y%s%H$K$h$kF~NO%G!<%?$N%A%'%C%/=hM}$G(B
> $B%(%i!<$,$"$C$?$i(B .SetFocus $B$G:FF~NO$7$F$b$i$&;v$r9M$($^$7$?!#(B

> $B$7$+$7!"(B

> '------$B%k!<%W$9$k(B
> Private Sub Text1_LostFocus()
>     If Not (Text1.Text = "1") Then
>         Call MsgBox("$BCM$,ITEv$G$9(B", vbOKOnly)
>         Text1.SetFocus
>     End If
> End Sub

> $B$N$h$&$J=hM}$@$H!"MxMQ<T$,@5$7$$CM$rF~NO$7$J$$8B$j(B
> $B%-%c%s%;%k$G$-$J$/$J$j$^$9!#(B
> $B;EJ}$,L5$$$N$G!"2s?t$K$h$k@)8B$r@_$1$^$7$?!#(B($B"(DI2CItJ,(B)

> '------$B2s?t@)8B(B
> Dim nErrorCount As Integer '$B"((B
> Private Sub Command1_Click()
>     Unload Me
> End Sub

> Private Sub Text1_Change()
>     nErrorCount = 0  '$B"((B
> End Sub

> Private Sub Text1_LostFocus()
>     If nErrorCount > 2 Then Exit Sub  '$B"((B
>     nErrorCount = nErrorCount + 1     '$B"((B
>     If Not (Text1.Text = "1") Then
>         Call MsgBox("$BCM$,ITEv$G$9(B", vbOKOnly)
>         Text1.SetFocus
>     End If
> End Sub


> $B%-%c%s%;%k%\%?%s$N(B _Click $B%$%Y%s%H$@$1$O!"(B
> Text_LostFocus $B$h$jM%@h$5$;$?$$$N$G$9$,!"(B
> $B$3$N$h$&$J$3$H$O2DG=$J$N$G$7$g$&$+!#(B
> $B$b$C$HNI$$J}K!$,$"$l$P!"%R%s%H$@$1$G$b65$($F$/$@$5$$!#(B

$B4JC1$K$O=PMh$J$$$G$7$g$&!#(B

Private Sub Text1_LostFocus()
    If Text1.Text = "" Then Exit Sub
    If Text1.Text <> "1" Then
         MsgBox "$BCM$,ITEv$G$9(B", vbExclamation
         Text1.SetFocus
    End If
End Sub

Private Sub Command2_Click()
    If Text1.Text == "" Then
        MsgBox "Text1$B$KCM$rF~NO$7$F2<$5$$(B", vbExclamation
	Text1.SetFocus
	Exit Sub
    End If
    '$B$=$N8e$N=hM}$r$3$3$X5-F~$7$F2<$5$$(B
End Sub

$B$3$N$h$&$K$9$k$H!"F~NOI,?\$K$7$?$$(BTextBox$B$NCM$r%A%'%C%/$9$k$3$H$,(B
$B$G$-$^$9!#(B
$BCM$,6u$J$i%-%c%s%;%k%\%?%s$r2!$;$^$9$7!"(B
$B<B9T%\%?%s$r2!$9$HCM$,F~NO$5$l$F$$$J$$>l9g$O!"$=$3$X%U%)!<%+%9$,(B
$B0\$j$^$9!#(B

Dim PrevFocus As String

Private Sub Form1_Load()
    Command2.Enabled = False
End Sub

Private Sub Text1_GotFocus()
    If PrevFocus = "Text2" Or PrevFocus = "Text3" Then
        CheckAll
    End If
    PrevFocus = "Text1"
End Sub

Private Sub Text2_GotFocus()
    If PrevFocus = "Text1" Or PrevFocus = "Text3" Then
        CheckAll
    End If
    PrevFocus = "Text2"
End Sub

Private Sub Text3_GotFocus()
    If PrevFocus = "Text1" Or PrevFocus = "Text2" Then
        CheckAll
    End If
    PrevFocus = "Text3"
End Sub

Private Sub Command1_Click()
    If PrevFocus = "Text1" Or PrevFocus = "Text2" Or PrevFocus = "Text3" Then
        CheckAll
    End If
End Sub

Private Sub CheckAll() As Boolean
    If PrevFocus = "Text1" Then
        If Text1.Text <> "1" Then
            MsgBox "$BCM$,ITEv$G$9(B", vbExclamation
            Text1.SetFocus
	    Command1.Enabled = False
            CheckAll = False
	    Exit Sub
        End If
    ElseIf PrevFocus = "Text2" Then
        If Text2.Text <> "2" Then
            MsgBox "$BCM$,ITEv$G$9(B", vbExclamation
            Text2.SetFocus
	    Command1.Enabled = False
            CheckAll = False
	    Exit Sub
        End If
    ElseIf PrevFocus = "Text3" Then
        If Text3.Text <> "3" Then
            MsgBox "$BCM$,ITEv$G$9(B", vbExclamation
            Text3.SetFocus
	    Command1.Enabled = False
            CheckAll = False
	    Exit Sub
        End If
    End If

    Command1.Enabled = True
    CheckAll = True
End Sub

Private Sub Command2_Click()
    '$B<B9T%\%?%s$N=hM}$r5-F~$7$F2<$5$$(B
End Sub

$B$b$C$H$-$l$$$J9=B$$G=q$1$k$H;W$$$^$9!#(B

$B$3$s$J46$8$K$9$l$P!"A4It$NF~NO9`L\$K@5>o$JCM$,@_Dj$5$l$k$^$G!"(B
$B<B9T%\%?%s$O2!$;$J$$!#(B
$B$=$N$+$o$j$K%-%c%s%;%k%\%?%s$J$i2!$;$k!#(B

$B$H$$$C$?>uBV$r:n$j=P$;$k$H;W$$$^$9!#(B

#VB$B$N4D6-$G;n$7$?Lu$G$O$J$$$N$G$$$$$+$2$s$G$9(B
#$B%(%G%#%?$G$=$N$^$^=q$$$?$b$N$G!&!&!&(B

$B$Q$C$H;W$$IU$/$N$O$3$l$i(B2$BDL$j$NJ}K!$/$i$$$G$9!#(B
$B%R%s%H$K$J$j$^$9$G$7$g$&$+(B?
-- 
Terushi Arakawa
mailto:bosturbo@bostn.tsn.or.jp
Technical Details
Message-ID: <622onn$t97@anise.bostn.tsn.or.jp>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3444A353.7A36@ffc.co.jp>

Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS
X-Google-Thread: 105c2e,7b595841ef62fd65
X-Google-Attributes: gid105c2e,public
From: bosturbo@anise.bostn.tsn.or.jp (Terushi Arakawa)
Subject: Re: _LostFocus + .SetFocus
Date: 1997/10/16
Message-ID: <622onn$t97@anise.bostn.tsn.or.jp>
X-Deja-AN: 281141093
References: <3444A353.7A36@ffc.co.jp>
Organization: TSN BBS(bostn), Chigasaki Kanagawa, Japan
Newsgroups: fj.lang.visualbasic