分类: 电脑/网络 >> 程序设计 >> 其他编程语言
问题描述:
我从网上下载了一个代码看看,地址是:bc-/Article/kfyy/vb/bcsl/200512/2466我把代码弄上去之后发现有一些错误,最关键的是其中的“AlarmTime”这个变量的类型以及格式问题。请大家帮忙看一下该怎么改?
代码如下;
Option Explicit
Dim AlarmTime '申明变量(这个样子定义变量行吗?是什么类型?)
Private Sub Command1_Click()
Call dialog '调用dialog子程序
End Sub
Private Sub Form_Load()
Command3Enabled = False '初始化时mand3为不可用的
AlarmTime=""(这样的话不就是当成字符串的形式了么?
End Sub
Private Sub Command2_Click()
AlarmTime = InputBox("请输入你想设定的时间,例如(19:12:00)", "小闹钟")
If AlarmTime = "Then Exit Sub"
If Not IsDate(AlarmTime) Then
MsgBox "你所输入的不是时间格式,请重试!", , "Wrong"
Else
AlarmTime = CDate(AlarmTime)
End If
'判断输入的是否可转换成time格式
'isdate函数是判断输入的是否可转换成date格式
End Sub
Private Sub Command3_Click()
Call deng
'调用deng子程序
End Sub
Private Sub Form_Click()
frmAboutShow
'显示关于对话框
End Sub
Private Sub Form_Resize()
If WindowState = 1 Then
Call mintime
Else
Caption = "小闹钟"
End If
'如果窗口被最小化,则调用mintime程序
End Sub
Private Sub mintime()
Caption = Format(Time, "long Time")
'使用长时间格式来显示时间
End Sub
Private Sub Timer1_Timer()
If lbltimeCaption <> CStr(Time) Then
lbltimeCaption = Time
End If
'显示时间每秒钟的变化
If Time >= AlarmTime Then
Call deng
End If
'判断如果现在的时间超过了设定的时间,则调用deng子程序
If WindowState = 1 Then
If Minute(CDate(Caption)) <> Minute(Time) Then
mintime
End If
End If
'最小化时显示时间每分钟的变化
End Sub
Sub dialog()
CommonDialog1Flags = cdlCFBoth
CommonDialog1ShowOpen
Label1Caption = CommonDialog1FileName
If Label1 <> " Then
Command3Enabled = -1
Else
Exit Sub
End If
'把打开的文件名给于label1
'如果label1不为空时,则mand3即可用
End Sub
Sub deng()
Dim ss
ss = Shell(Label1Caption, 1)
End
'启动指定的文件,并且结束小闹钟程序
End Sub
括号里面的都是错误的地方,希望各位帮我看看怎么错了谢谢啊。
解析:
修改完毕,并添加了注释
-------------------------------------------
Option Explicit
Dim AlarmTime '申明变量(这个样子定义变量行吗?是什么类型?)
'将AlarmTime申明为变体型(Variant)
Private Sub Command1_Click()
Call dialog '调用dialog子程序
End Sub
Private Sub Form_Load()
Command3Enabled = False '初始化时mand3为不可用的
AlarmTime = "" '(这样的话不就是当成字符串的形式了么?
'此时AlarmTime为字符串型(String)
End Sub
Private Sub Command2_Click()
'AlarmTime = InputBox("请输入你想设定的时间,例如(19:12:00)", "小闹钟")
AlarmTime = InputBox("请输入你想设定的时间,例如(19:12:00)", "小闹钟")
'此时AlarmTime为字符串型(String)
'If AlarmTime = "Then Exit Sub"
If AlarmTime = "" Then Exit Sub
If Not IsDate(AlarmTime) Then
MsgBox "你所输入的不是时间格式,请重试!", , "Wrong"
Else
AlarmTime = CDate(AlarmTime)
'此时AlarmTime为日期型(Date)
End If
'判断输入的是否可转换成time格式
'isdate函数是判断输入的是否可转换成date格式
End Sub
Private Sub Command3_Click()
Call deng
'调用deng子程序
End Sub
Private Sub Form_Click()
frmaboutShow
'显示关于对话框
End Sub
Private Sub Form_Resize()
If WindowState = 1 Then
Call mintime
Else
Caption = "小闹钟"
End If
'如果窗口被最小化,则调用mintime程序
End Sub
Private Sub mintime()
Caption = Format(Time, "long Time")
'使用长时间格式来显示时间
End Sub
Private Sub Timer1_Timer()
If lbltimeCaption <> CStr(Time) Then
lbltimeCaption = Time
End If
'显示时间每秒钟的变化
If Time >= AlarmTime Then
Call deng
End If
'判断如果现在的时间超过了设定的时间,则调用deng子程序
If WindowState = 1 Then
If Minute(CDate(Caption)) <> Minute(Time) Then
mintime
End If
End If
'最小化时显示时间每分钟的变化
End Sub
Sub dialog()
CommonDialog1Flags = cdlCFBoth
CommonDialog1ShowOpen
Label1Caption = CommonDialog1FileName
'If Label1 <> " Then
If Label1 <> "" Then
Command3Enabled = -1
Else
Exit Sub
End If
'把打开的文件名给于label1
'如果label1不为空时,则mand3即可用
End Sub
Sub deng()
Dim ss
ss = Shell(Label1Caption, 1)
End
'启动指定的文件,并且结束小闹钟程序
End Sub
要想设置一个有勇气的闹钟,首先需要明确自己的目标和愿望,以及需要克服的难关。然后,可以按照以下步骤设置:
1 选择一个有意义的铃声或音乐,可以是激励人心的歌曲或声音,让自己在听到闹钟时立刻进入状态。
2 设定闹钟的时间,要考虑到自己的工作和生活规律,确保有足够的时间完成任务。
3 在闹钟上设置提醒事项,可以是自己需要完成的重要任务或目标,也可以是需要克服的难关,如克服恐惧、面对挑战等。
4 设置闹钟的振动模式,可以选择震动或声音或两者结合,让自己在不同的环境下都能收到提醒。
5 在闹钟上加入鼓励的话语或标语,可以是自己喜欢的名言或励志语句,让自己在听到闹钟时感到振奋和鼓舞。
6 注意闹钟的摆放位置,放在自己能看到的地方,以便在需要时能够看到提醒事项和鼓励语句。
7 在闹钟响起时,不要马上关闭,要用积极的心态面对提醒事项和难关,勇敢地面对挑战,克服自己的恐惧和不安。
总之,一个有勇气的闹钟不仅仅是一个简单的时间提醒器,它可以成为自己的鼓励和激励,提醒自己勇敢面对生活中的挑战和难关,不断成长和进步。
首先,先设置一下闹钟响铃时间,然后查看状态栏处的闹钟图标是否显示,若显示说明则说明闹钟正在后台运行。打开360手机卫士或其他优化软件,在忽略名单里查看是否忽略了闹钟程序,若没有,那么一旦执行清理内存时便结束了闹钟程序。还有可能是闹钟铃声静音了。打开闹钟程序,按手机底部的menu键,打开“设置”,然后点击“闹钟音量”,加大闹钟的音量,不要静音。点击“默认闹钟设置”,查看是否没有选择闹钟铃声,将其设置成“无”了,若是,则设置一个有声音的铃声。
利用Visual C++设计一个闹钟程序,定时事件提醒等。本题目涉及使用设备上下文进行绘图和定时器的应用。
功能要求:
1表盘界面的显示,显示当前时间。
2设置交互界面,用以设置时间信息和选择提示事件。
3用户可以输入特定时间和选择播放声音或闪动指示灯来提醒用户。
4具有秒表功能。
设计提示:
1应用程序框架设计。
2程序菜单设计。
3程序对话框设计。
4表盘绘图程序设计。
5事件定时提醒功能设计。
#include<graphicsh>
#include<conioh>
#include<mathh>
#include<dosh>
#include<stdioh>
void main()
{
int gd=DETECT,gm;
int x=320,y=240,r=200,i,h,m,s,thetamin,thetasec;
struct time t;
char n[12][3]={"3","2","1","12","11","10","9","8","7","6","5","4"};
initgraph(&gd,&gm,"C:\Win-TC\bgi");//图形驱动器路径,根据自己的系统更换!
circle(x,y,210);
setcolor(4);
settextstyle(4,0,5);
for(i=0;i<12;i++)
{
if(i!=3)
outtextxy(x+(r-14)cos(M_PI/6i)-10,y-(r-14)sin(M_PI/6i)-26,n[i]);
else
outtextxy(x+(r-14)cos(M_PI/6i)-20,y-(r-14)sin(M_PI/6i)-26,n[i]);
}
gettime(&t);
printf("The current time is: %2d:%02d:%02d%02d\n",tti_hour, tti_min,
tti_sec, tti_hund);
while(!kbhit())
{
setcolor(5);
setfillstyle(1,5);
circle(x,y,10);
floodfill(x,y,5);
gettime(&t);
if(tti_min!=m)
{
setcolor(0);
line(x,y,x+(r-60)cos(thetamin(M_PI/180)),y-(r-60)sin(thetamin(M_PI/180
)));
circle(x+(r-80)cos(thetamin(M_PI/180)),y-(r-80)sin(thetamin(M_PI/180))
,10);
line(x,y,x+(r-110)cos(M_PI/6h-((m/2)(M_PI/180))),y-(r-110)sin(M_PI/6h
-((m/2)(M_PI/180))));
circle(x+(r-130)cos(M_PI/6h-((m/2)(M_PI/180))),y-(r-130)sin(M_PI/6h-(
(m/2)(M_PI/180))),10);
}
if(tti_hour>12)
tti_hour=tti_hour-12;
if(tti_hour<4)
h=abs(tti_hour-3);
else
h=15-tti_hour;
m=tti_min;
if(tti_min<=15)
thetamin=(15-tti_min)6;
else
thetamin=450-tti_min6;
if(tti_sec<=15)
thetasec=(15-tti_sec)6;
else
thetasec=450-tti_sec6;
setcolor(4);
line(x,y,x+(r-110)cos(M_PI/6h-((m/2)(M_PI/180))),y-(r-110)sin(M_PI/6h
-((m/2)(M_PI/180))));
circle(x+(r-130)cos(M_PI/6h-((m/2)(M_PI/180))),y-(r-130)sin(M_PI/6h-(
(m/2)(M_PI/180))),10);
line(x,y,x+(r-60)cos(thetamin(M_PI/180)),y-(r-60)sin(thetamin(M_PI/180
)));
circle(x+(r-80)cos(thetamin(M_PI/180)),y-(r-80)sin(thetamin(M_PI/180))
,10);
setcolor(15);
line(x,y,x+(r-70)cos(thetasec(M_PI/180)),y-(r-70)sin(thetasec(M_PI/180
)));
delay(1000);
setcolor(0);
line(x,y,x+(r-70)cos(thetasec(M_PI/180)),y-(r-70)sin(thetasec(M_PI/180
)));
}
}
//我已通过Turbo C++30编译,给分!
以上就是关于人求助关于VB编写小闹钟的程序。全部的内容,包括:人求助关于VB编写小闹钟的程序。、闹钟怎么设置勇气大爆发、设置手机闹钟等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)