Article View: cn.bbs.comp.lang.visual-basic
Article #105Re: ��ţ�ܲ��ܰ�æ������ҵ����
From: һ����ˮ
Date: Sat, 23 Dec 2006 23:44
Date: Sat, 23 Dec 2006 23:44
80 lines
4725 bytes
4725 bytes
�������˼������������ˣ���������Ҳ�ܼ��Լ��������������
5-7
���������ҳ�1-100֮���������ʹ�������Ϊƽ��������5��4��10��6��13��12�ĺ�
����Ϊƽ�����ڴ���������������ť�����г���ʱ����������ʼ�����ť���ڴ�
�����1-100��������ƽ��������������ť���������
Private Sub Command1_Click()
Dim i As Integer, j As Integer, A As Single, B As Single
For i = 1 To 99
For j = i + 1 To 100
A = Round((j + i) ^ 0.5, 1): B = Round((j - i) ^ 0.5, 1)
If A = Int(A) And B = Int(B) Then Print Str(i) & "," & Str(j) & vbCrLf
Next
Next
End Sub
5-9
���һ���������֮�͵��������ı��?����������Ϊ����ȫ�����磬����28����
��Ϊ1��2��4��7��14�����1+2+4+7+14=28�����28��һ����ȫ���дһ�����Ӽ�����
��������M��N, ���M��N֮���������ȫ��
Private Sub Command1_Click()
Dim st As String, A As Long, B As Long, i As Long, j As Long, dat As Long
st = InputBox("�������һ������"): A = Val(st)
st = InputBox("������ڶ�������"): B = Val(st)
If B < A Then B = A: A = Val(st)
For i = A To B
dat = 0
For j = 1 To i - 1
If i / j = i \ j Then dat = dat + j
Next
If dat = i Then Print Str(i) & vbCrLf
Next
End Sub
6-6
�ƶ���Ļ�����һ�����壬ʹ��Timer�ؼ���̣���������ʼ�����ť���ڴ����ϵ���Ļ��
ʼ�ƶ�����Ļ����Ϊ: ��Visual Basic��ӭ������ĻΪ��ɫ����2���֣���Ļ�ƶ���ʱ��
���Ϊ1/20�롣�������������ť���������
Option Explicit
Dim st As String, x As Integer
Private Sub Command1_Click()
st = "Visual Basic��ӭ����"
x = (Width - TextWidth(st)) / 2
Timer1.Enabled = True
Timer1.Interval = 200
Debug.Print Width, x
End Sub
Private Sub Timer1_Timer()
Cls
CurrentX = x: CurrentY = 1000
Print st
st = Right(st, Len(st) - 1) & Left(st, 1)
End Sub
7-5
��д���Dec_Num�������ж����Ƿ�Ϊ���������һ��������Ӹ�λ����λ�ϵ����ֵͼ���
��ƴ���Ϊ����������5431��98772�ȶ��ǽ��������¼�����У��Ӽ���������һ������
�����ó���Dec_Num����жϸ����Ƿ�Ϊ�����������ڴ����������
Private Sub Command1_Click()
Dim st As String
st = InputBox("������һ��2λ�����ϵ�������")
If Len(st) < 2 Then Exit Sub
If Val(st) < 10 Then Exit Sub
Print st & IIf(Dec_Num(st), "", "��") & "��һ��������"
End Sub
Function Dec_Num(Num As String) As Boolean
Dim i As Integer, A As String, B As String, BJ As Boolean
For i = 1 To Len(Num) - 1
A = Mid(Num, i, 1): B = Mid(Num, i + 1, 1)
If Val(A) <= Val(B) Then BJ = True: Exit For
Next
Dec_Num = Not BJ
End Function
Technical Details
Message-ID:
<emibfd$sat$1@news.cn99.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!198.186.190.251.MISMATCH!news-out.readnews.com!transit4.readnews.com!panix!bloom-beacon.mit.edu!news.cn99.com!not-for-mailReferences:
<4RcNBa$68i@newsmth.net>Show Full Headers
Complete Article Headers
X-Google-Thread: 109fdd,5d6aee0b6b49f836 X-Google-Attributes: gid109fdd,public X-Google-Language: Chinese,GB Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!198.186.190.251.MISMATCH!news-out.readnews.com!transit4.readnews.com!panix!bloom-beacon.mit.edu!news.cn99.com!not-for-mail From: "һ����ˮ" <wangzhichao_812@msn.com> Newsgroups: cn.bbs.comp.lang.visual-basic Subject: Re: ��ţ�ܲ��ܰ�æ������ҵ���� Date: Sat, 23 Dec 2006 11:44:24 -1200 Organization: Bentium Ltd. (CN99) Lines: 82 Message-ID: <emibfd$sat$1@news.cn99.com> References: <4RcNBa$68i@newsmth.net> NNTP-Posting-Host: 222.245.30.142 X-Trace: news.cn99.com 1166848301 29021 222.245.30.142 (23 Dec 2006 04:31:41 GMT) X-Complaints-To: usenet@news.cn99.com NNTP-Posting-Date: Sat, 23 Dec 2006 04:31:41 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-RFC2646: Format=Flowed; Original