Private Sub Text1_Change()
Text2.Text = Text1.Text
End Sub
题目二:
Private Sub Command1_Click()
Text1.Text = "程序设计第一步:设计界面"
End Sub
Private Sub Command2_Click()
Text1.Text = "程序设计第二步:属性设置"
End Sub
Private Sub Command3_Click()
Text1.Text = "程序设计第三步:编写代码"
End Sub
题目三:
Private Sub Command1_Click()
Text1.PasswordChar = "*"
End Sub
题目四:
运消隐行结果:
23
23
23
hellonihao
hellonihao
hello 100
helloI
100nihao
Inihao
..........先写这么多 - - 先睡觉去了。。亮态。明儿再敬桥源说!
1. 如何画圆?Circle (x, y), r, vbRed
2. 如何记录闹时间?
使用数组来存储闹时信息。
Dim NaoShi(0 To 3) As String '存储闹时时间
3. 如何设置闹时时间?
在文本框Text1.Text中输入所需要的时间,通过如下方法,将闹时时间基茄磨添加到List1中显示
List1.AddItem Text1.Text
4. 如何实现闹时判断?纳携
For I = 0 To 3
k = NaoShi(I)
If k = Label1.Caption Then
PlaySound1.URL = App.Path &RingFile
End If
Next
5. 如何设置和显示12小制?
Label1.Caption = Format(Time, "hh:mm:ss AM/PM")
6. 如何整点报时?
s = Second(Time)
m = Minute(Time)
h = Hour(Time)
If m = 0 And s = 0 Then
PlaySound1.URL = App.Path &"\bibi.wav"
End If
7. 如何绘制电子钟时分刻度?
Dim X, Y, rn As Single
Dim x0, y0 As Single
Dim I As Integer
x0 = Shape2(1).Left + Shape2(1).Width / 2
y0 = Shape2(1).Top + Shape2(1).Height / 2
rn = len_S + 100
FillStyle = 0
For I = 1 To 60
X = x0 + rn * Sin(pi * I / 30)
Y = y0 + rn * Cos(pi * I / 30)
If (I Mod 5 = 0) Then
FillColor = vbRed
Circle (X, Y), 100, vbRed '时的刻度
Else
FillColor = vbBlue
Circle (X, Y), 50, vbBlue '分的刻度
End If
Next I
8. 时、分、秒针的长度的计算。
len_S = Sqr((LineS.Y2 - LineS.Y1) ^ 2 + (LineS.X2 - LineS.X1) ^ 2) '秒针长度
len_M = Sqr((LineM.Y2 - LineM.Y1) ^ 2 + (LineM.X2 - LineM.X1) ^ 2) '分针长度
len_H = Sqr((LineH.Y2 - LineH.Y1) ^ 2 + (LineH.X2 - LineH.X1) ^ 2) '时针长度
9. 如何播放单个语音?
10. 如何连续播放语音?
1)时间的分解与语音播放文件的生成
' 语音报时模块
Dim s, m, h, I, n As Byte
Dim TimeNum(6) As Integer
'时间的获得
s = Second(Time)
m = Minute(Time)
h = Hour(Time)
'时间的分搏斗解
TimeNum(0) = Int(h / 10)
TimeNum(1) = h Mod 10
TimeNum(2) = Int(m / 10)
TimeNum(3) = m Mod 10
TimeNum(4) = Int(s / 10)
TimeNum(5) = s Mod 10
'语音文件名
I = 0
n = 0
If TimeNum(n) = 0 Then
n = n + 1
Sound(I) = "T" &Format(TimeNum(n), "00") &".wav"
Else
Sound(I) = "T" &Format(TimeNum(n), "00") &".wav"
I = I + 1
Sound(I) = "Shi.wav"
n = n + 1
If TimeNum(n) Then
I = I + 1
Sound(I) = "T" &Format(TimeNum(n), "00") &".wav"
End If
End If
'这时只给出时的分解与播放文件名处理。
2)通过定时器2进行定时,每隔一定时间,播放一个文件。Playlist数组中事先保存有时分秒所对应的语句文件名。
Private Sub Timer2_Timer()
PlaySound1.URL = Sound(Playlist)
If Playlist = PlayCont Then
Timer2.Interval = 0
Else
Playlist = Playlist + 1
End If
End Sub
11. 光标定位与校时修改实现
Option Explicit
Dim Temp As Variant
Dim SetStatus As Integer
Dim CurMinute, CurHour, CurSecond As Integer
Dim CurTime As Variant
Const EM_GETSEL = &HB0
Const EM_LINEFROMCHAR = &HC9
Const EM_LINEINDEX = &HBB
Dim LineNo As Long, ColNo As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Sub GetCaretPos(ByVal TextHwnd As Long, LineNo As Long, ColNo As Long)
Dim I As Long, J As Long
Dim lParam As Long, wParam As Long
Dim k As Long
'首先向文本框传递EM_GETSEL消息以获取从起始位置到
'光标所在位置的字符数
I = SendMessage(TextHwnd, EM_GETSEL, wParam, lParam)
J = I / 2 ^ 16
'再向文本框传递EM_LINEFROMCHAR消息根据获得的字符
'数确定光标以获取所在行数
LineNo = SendMessage(TextHwnd, EM_LINEFROMCHAR, J, 0)
LineNo = LineNo + 1
'向文本框传递EM_LINEINDEX消息以获取所在列数
k = SendMessage(TextHwnd, EM_LINEINDEX, -1, 0)
ColNo = J - k + 1
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
CurTime = Format(Time, "hh:mm:ss")
Text1.Text = CurTime
SetStatus = 1
CurHour = Hour(CurTime)
CurMinute = Minute(CurTime)
CurSecond = Second(CurTime)
VScroll1.Value = CurHour
VScroll1.Min = -1
Text1.MaxLength = 8
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Call GetCaretPos(Text1.hwnd, LineNo, ColNo)
Select Case ColNo
Case 1 To 3
SetStatus = 1
VScroll1.Max = 24
VScroll1.Value = CurHour
Case 4 To 6
SetStatus = 2
VScroll1.Max = 60
VScroll1.Value = CurMinute
Case 7 To 9
SetStatus = 3
VScroll1.Max = 60
VScroll1.Value = CurSecond
End Select
'Label1.Caption = ColNo
End Sub
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call GetCaretPos(Text1.hwnd, LineNo, ColNo)
Select Case ColNo
Case 1 To 3
Text1.SelStart = 0
Text1.SelLength = 2
SetStatus = 1
VScroll1.Max = 24
VScroll1.Value = CurHour
Case 4 To 6
Text1.SelStart = 3
Text1.SelLength = 2
SetStatus = 2
VScroll1.Max = 60
VScroll1.Value = CurMinute
Case 7 To 9
Text1.SelStart = 6
Text1.SelLength = 2
SetStatus = 3
VScroll1.Max = 60
VScroll1.Value = CurSecond
End Select
End Sub
Private Sub VScroll1_Change()
Dim tt, nSelstart As Integer
tt = VScroll1.Value
Select Case SetStatus
Case 1
If tt = 24 Then
tt = 0
VScroll1.Value = 0
End If
If tt <0 Then
tt = 23
VScroll1.Value = 23
End If
Temp = tt &":" &CurMinute &":" &CurSecond
nSelstart = 0
Case 2
If tt = 60 Then
tt = 0
VScroll1.Value = 0
End If
If tt <0 Then
tt = 59
VScroll1.Value = 59
End If
Temp = CurHour &":" &tt &":" &CurSecond
nSelstart = 3
Case 3
If tt = 60 Then
tt = 0
VScroll1.Value = 0
End If
If tt <0 Then
tt = 59
VScroll1.Value = 59
End If
Temp = CurHour &":" &CurMinute &":" &tt
nSelstart = 6
End Select
Text1.Text = Format(Temp, "hh:mm:ss")
Time = Temp
'Text1.SetFocus
Text1.SelStart = nSelstart
Text1.SelLength = 2
End Sub
帮楼主提供以上详细信息,不过偶不会编。。。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)