4. н¨Ò»¸ö¹¤³Ì£¬Íê³É¡°ÅжÏÖÊÊý¡±Ó¦ÓóÌÐòµÄÉè¼Æ¡£¾ßÌåÒªÇóÈçÏ£º ²Î¿¼´ð°¸£º
Private Sub Command1_Click() Dim n As Integer, i As Integer n = Text1.Text For i = 2 To Sqr(n)
If n Mod i = 0 Then Exit For Next i
If i > Sqr(n) Then
Label2.Caption = Label2.Caption + \ÊÇÖÊÊý\ Else
Label2.Caption = Label2.Caption + \²»ÊÇÖÊÊý\ End If End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
MsgBox(\ÊäÈëµÄ²»ÊÇÊý×Ö, ÎÞ·¨¼ÆËã\ End If End Sub
5. н¨Ò»¸ö¹¤³Ì£¬Íê³É¡°¼ÆËãÆ½¾ù³É¼¨¡±Ó¦ÓóÌÐòµÄÉè¼Æ¡£¾ßÌåÒªÇóÈçÏ£º ²Î¿¼´ð°¸£º
Private Sub Text1_Change()
Text4.Text = Str((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3) End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
n = MsgBox(\ÊäÈëµÄ²»ÊÇÊý×Ö, ÎÞ·¨¼ÆËã\ End If End Sub
Private Sub Text2_Change()
Text4.Text = Str((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3) End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
n = MsgBox(\ÊäÈëµÄ²»ÊÇÊý×Ö, ÎÞ·¨¼ÆËã\ End If End Sub
Private Sub Text3_Change()
Text4.Text = Str((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3) End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
n = MsgBox(\ÊäÈëµÄ²»ÊÇÊý×Ö, ÎÞ·¨¼ÆËã\ End If End Sub
Private Sub Text4_Change() Text4.Locked = True End Sub
6. н¨Ò»¸ö¹¤³Ì£¬Íê³É¡°ÊÕ¿î¼ÆË㡱³ÌÐòµÄÉè¼Æ¡£¾ßÌåÒªÇóÈçÏ£º ²Î¿¼´ð°¸£º
Private Sub Command1_Click() Text1.Text = \Text2.Text = \Text3.Text = \Text1.setfocus End Sub
Private Sub Command2_Click()
Text3.Text = Str(Val(Text1.Text) * Val(Text2.Text)) End Sub
7. н¨Ò»¸ö¹¤³Ì£¬Íê³É¡°±à¼¡±³ÌÐòµÄÉè¼Æ¡£¾ßÌåÒªÇóÈçÏ£º ²Î¿¼´ð°¸£º
Private Sub Command1_Click() '½«Îı¾¿òÑ¡ÖеÄÄÚÈݸ´ÖƵ½¼ôÕ³°åÖÐ Clipboard.SetText Text1.SelText End Sub
Private Sub Command2_Click()
Clipboard.SetText Text1.SelText Text1.SelText = \End Sub
Private Sub Command3_Click()
Text1.SelText = Clipboard.GetText() '½«ÒªÕ³ÌùµÄÄÚÈݸ´ÖƵ½¹â±êËùÔÚ´¦ End Sub
Private Sub Command4_Click() 'ɾ³ý Text1.seltext=¡±¡± End Sub
Private Sub Form_Load() Form1.Caption = \±à¼\ Form1.BorderStyle = 1 Command1.Caption = \¸´ÖÆ\ Command2.Caption = \¼ôÇÐ\ Command3.Caption = \Õ³Ìù\ Command4.Caption = \ɾ³ý\End Sub
8. н¨Ò»¸ö¹¤³Ì£¬Íê³É¡°ÃÜÂë¼ìÑ顱³ÌÐòµÄÉè¼Æ¡£¾ßÌåÒªÇóÈçÏ£º ²Î¿¼´ð°¸£º
Private Sub Command1_Click() End End Sub
Private Sub Form_Load() Label2.Visible = False Label2.AutoSize = True Text1.PasswordChar = \End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer) Static times As Integer 'ͳ¼ÆµÚ¼¸´ÎÊäÈëÃÜÂë ' °´»Ø³µ¼üºó½øÐÐÃÜÂë¼ìÑé If KeyAscii = 13 Then
If Text1.Text = \ Label2.Caption = \»¶Ó¹âÁÙ£¡\ Label2.Visible = True Else
If times < 2 Then
Label2.Caption = \ÃÜÂë²»·û£¬ÇëÔÙÊäÈëÒ»±é£¡\ Label2.Visible = True Text1.Text = \ Else
Label2.Caption = \·Ç·¨Óû§£¬ÇëÍ˳ö³ÌÐò£¡\ Text1.Text = \
Text1.Enabled = False End If End If
times = times + 1 End If End Sub
9. н¨Ò»¸ö¹¤³Ì£¬Íê³ÉÓ¦ÓóÌÐòµÄÉè¼Æ¡£¾ßÌåÒªÇóÈçÏ£º ²Î¿¼´ð°¸£º
Private Sub Command1_Click()
If Text1.Text = Text2.Text And Text1.Text = \If Text3.Text = Text4.Text And Text3.Text <> \MsgBox (\ÃÜÂëÐ޸ijɹ¦\Else
MsgBox (\ÇëÖØÐÂÊäÈëÐÂÃÜÂë\End If Else
MsgBox (\ÇëÖØÐÂÊäÈëÓû§Ãû»òÃÜÂë\End If End Sub
Private Sub Command2_Click() End End Sub
Private Sub Form_Load() Text1.TabIndex = 0 Text2.TabIndex = 1 Text3.TabIndex = 2 Text4.TabIndex = 3
Command1.TabIndex = 4 Command2.TabIndex = 5 End Sub
10. н¨Ò»¸ö¹¤³Ì£¬Íê³ÉÓ¦ÓóÌÐòµÄÉè¼Æ¡£¾ßÌåÒªÇóÈçÏ£º ²Î¿¼´ð°¸£º
Private Sub Command1_Click() Dim ss As String
For i = 1 To Len(aa(Text1.Text)) ss = aa(Text1.Text) Print Mid(ss, i, 1) Next i
Command1.Enabled = False
End Sub
Private Sub Command2_Click() End End Sub
Function aa(ss As String) As String Dim x() As Integer Dim temp As Integer ReDim x(Len(ss)) For i = 1 To Len(ss) x(i) = Asc(Mid(ss, i, 1)) Next i
For i = 1 To Len(ss) For j = 1 To Len(ss) If x(i) < x(j) Then temp = x(i) x(i) = x(j) x(j) = temp End If Next j Next i
For i = 1 To Len(ss) aa = aa & Chr(x(i)) Next i
End Function
11. н¨Ò»¸ö¹¤³Ì£¬Íê³É¡°Ìæ»»¡±³ÌÐòµÄÉè¼Æ¡£¾ßÌåÒªÇóÈçÏ£º ²Î¿¼´ð°¸£º
Private Sub command1_Click() ' ²éÕÒÌæ»»Îı¾ Dim i%, len1%, len2% Dim findstr As String findstr = Text2.Text
findstrlen = Len(findstr) ' ´ý²éÎı¾³¤¶È text1len = Len(Text1.Text) ' Îı¾³¤¶È For i = 1 To text1len
If InStr(Text1.Text, findstr) Then start = InStr(Text1.Text, findstr) Text1.SetFocus
Text1.SelStart = start - 1 Text1.SelLength = findstrlen
Text1.SelText = Text3.Text ' Ìæ»»Îı¾ End If Next i End Sub
Ïà¹ØÍÆ¼ö£º