百度
360搜索
搜狗搜索

vb课程设计实例,VB课程设计,谁能帮帮我!!!详细介绍

本文目录一览: VB课程设计,谁能帮帮我!!!

邮箱拿来我发给你个压缩包对你也许有用
下班了。明天吧
一、 内容
用VB语言制作《Visual Basic语言程序设计》的教学课件。
二、说明
在所学教材中任选一章作为课件内容:
三、要求
1.课件中必须包含内容学习、例题演示、作业部分
2.内容全面、重点突出;有必要的动画演示。
3.界面友好、美观,易于操作。
4.课件演示的内容用文件保存。
四、参考书籍
《Visual Basic 使用大全》
没有什么复杂的问题,随便给你一个:
一个普通的计算器程序:
Option Explicit
Dim FirstNumber, NumberBuffer As Double
Dim chr As String
Dim EnterDecimal, ScaleCodeState As Boolean
Dim ScaleCode As Integer
Dim ScaleSymbol(0 To 7) As String
Private Sub Init()
EnterDecimal = False
Label1.Caption = "0"
FirstNumber = 0
ScaleCode = 0
ScaleCodeState = False
Label2.Caption = ""
End Sub
Private Sub ClearAll_Click()
Call Init
End Sub
Private Sub CurrentCls_Click()
Label1.Caption = ""
NumberBuffer = Val(Label1.Caption)
End Sub
Private Sub DecimalKey_Click()
If EnterDecimal = False Then
EnterDecimal = True
Label1.Caption = Label1.Caption + "."
NumberBuffer = Val(Label1.Caption)
End If
End Sub
Private Sub Form_Load()
Call Init
ScaleSymbol(0) = "+"
ScaleSymbol(1) = "-"
ScaleSymbol(2) = "*"
ScaleSymbol(3) = "/"
ScaleSymbol(4) = "^"
ScaleSymbol(5) = "1/X"
ScaleSymbol(6) = "%"
ScaleSymbol(7) = "S"
End Sub
Private Sub NumberKey_Click(Index As Integer)
chr = Val(Index)
If Left(Label1.Caption, 1) = "0" And Mid(Label1.Caption, 2, 1) <> "." Then _
Label1.Caption = Right(Label1.Caption, Len(Label1.Caption) - 1)
If Len(Label1.Caption) < 20 Then
If ScaleCodeState = True Then
ScaleCodeState = False
Label1.Caption = ""
End If
Label1.Caption = Label1.Caption + chr
NumberBuffer = Val(Label1.Caption)
End If
End Sub
Private Sub ScaleKey_Click(Index As Integer)
ScaleCode = Index
EnterDecimal = False
FirstNumber = NumberBuffer
ScaleCodeState = True
Label2.Caption = ScaleSymbol(Index)
End Sub
Private Sub Equal_Click()
Select Case ScaleCode
Case 0
NumberBuffer = FirstNumber + NumberBuffer
Case 1
NumberBuffer = FirstNumber - NumberBuffer
Case 2
NumberBuffer = FirstNumber * NumberBuffer
Case 3
NumberBuffer = FirstNumber / NumberBuffer
Case 4
NumberBuffer = FirstNumber ^ 2
Case 5
NumberBuffer = 1 / FirstNumber
Case 6
NumberBuffer = FirstNumber / 100
Case 7
NumberBuffer = Sqr(FirstNumber)
End Select
Label1.Caption = Str(NumberBuffer)
FirstNumber = NumberBuffer
EnterDecimal = False
ScaleCodeState = True
End Sub
Private Sub Space_Click()
If Len(Label1.Caption) > 1 Then
Label1.Caption = Left(Label1.Caption, Len(Label1.Caption) - 1)
Else
Label1.Caption = "0"
End If
NumberBuffer = Val(Label1.Caption)
End Sub

关于VB的课程设计

自己参照数据改一下应该就可以了。
#include

/*引用库函数*/

#include

#include

#include

typedef struct /*定义结构体数组*/

{

char num[10]; /*学号*/

char name[20]; /*姓名*/

int score; /*成绩*/

}Student;

Student stu[80]; /*结构体数组变量*/

int menu_select() /*菜单函数*/

{

char c;

do{

system("cls"); /*运行前清屏*/

printf("\t\t****Students' Grade Management System****\n"); /*菜单选择*/

printf("\t\t | 1. Input Records |\n");

printf("\t\t | 2. Display All Records |\n");

printf("\t\t | 3. Sort |\n");

printf("\t\t | 4. Insert a Record |\n");

printf("\t\t | 5. Delete a Record |\n");

printf("\t\t | 6. Query |\n");

printf("\t\t | 7. Statistic |\n");

printf("\t\t | 8. Add Records from a Text File|\n");

printf("\t\t | 9. Write to a Text file |\n");

printf("\t\t | 0. Quit |\n");

printf("\t\t*****************************************\n");

printf("\t\t\tGive your Choice(0-9):");

c=getchar(); /*读入选择*/

}while(c<'0'||c>'9');

return(c-'0'); /*返回选择*/

}

int Input(Student stud[],int n) /*输入若干条记录*/

{int i=0;

char sign,x[10]; /*x[10]为清除多余的数据所用*/

while(sign!='n'&&sign!='N') /*判断*/

{ printf("\t\t\tstudent's num:"); /*交互输入*/

scanf("\t\t\t%s",stud[n+i].num);

printf("\t\t\tstudent's name:");

scanf("\t\t\t%s",stud[n+i].name);

printf("\t\t\tstudent's score:");

scanf("\t\t\t%d",&stud[n+i].score);

gets(x); /*清除多余的输入*/

printf("\t\t\tany more records?(Y/N)");

scanf("\t\t\t%c",&sign); /*输入判断*/

i++;

}

return(n+i);

}

void Display(Student stud[],int n) /*显示所有记录*/

{

int i;

printf("\t\t\t-----------------------------------\n"); /*格式头*/

printf("\t\t\tnumber name score\n");

printf("\t\t\t-----------------------------------\n");

for(i=1;i
<n+1;i++) *循环输入*
{

printf("\t\t\t%-16s%-15s%d\n",stud[i-1].num,stud[i-1].name,stud[i-1].score);

if(i>1&&i%10==0) /*每十个暂停*/

{printf("\t\t\t-----------------------------------\n"); /*格式*/

printf("\t\t\t");

system("pause");

printf("\t\t\t-----------------------------------\n");

}

}

printf("\t\t\t");

system("pause");

}

void Sort_by_num(Student stud[],int n) /*按学号排序*/

{ int i,j,*p,*q,s;

char t[10];

for(i=0;i
<n-1;i++) *冒泡法排序*
for(j=0;j
<n-1-i;j++)
if(strcmp(stud[j].num,stud[j+1].num)>0)

{strcpy(t,stud[j+1].num);

strcpy(stud[j+1].num,stud[j].num);

strcpy(stud[j].num,t);

strcpy(t,stud[j+1].name);

strcpy(stud[j+1].name,stud[j].name);

strcpy(stud[j].name,t);

p=&stud[j+1].score;

q=&stud[j].score;

s=*p;

*p=*q;

*q=s;

}

}

int Insert_a_record(Student stud[],int n) /*插入一条记录*/

{char x[10]; /*清除多余输入所用*/

printf("\t\t\tstudent's num:"); /*交互式输入*/

scanf("\t\t\t%s",stud[n].num);

printf("\t\t\tstudent's name:");

scanf("\t\t\t%s",stud[n].name);

printf("\t\t\tstudent's score:");

scanf("\t\t\t%d",&stud[n].score);

gets(x);

n++;

Sort_by_num(stud,n); /*调用排序函数*/

printf("\t\t\tInsert Successed!\n"); /*返回成功信息*/

return(n);

}

int Delete_a_record(Student stud[],int n) /*按姓名查找,删除一条记录*/

{ char s[20];

int i=0,j;

printf("\t\t\ttell me his(her) name:"); /*交互式问寻*/

scanf("%s",s);

while(strcmp(stud[i].name,s)!=0&&i
<n) i++; *查找判断*
if(i==n)

{ printf("\t\t\tnot find!\n"); /*返回失败信息*/

return(n);

}

for(j=i;j
<n-1;j++) *删除操作*
{

strcpy(stud[j].num,stud[j+1].num);

strcpy(stud[j].name,stud[j+1].name);

stud[j].score=stud[j+1].score;

}

printf("\t\t\tDelete Successed!\n"); /*返回成功信息*/

return(n-1);

}

void Query_a_record(Student stud[],int n) /*查找并显示一个记录*/

{ char s[20];

int i=0;

printf("\t\t\tinput his(her) name:"); /*交互式输入*/

scanf("\t\t\t%s",s);

while(strcmp(stud[i].name,s)!=0&&i
<n) i++; *查找判断*
if(i==n)

{ printf("\t\t\tnot find!\n"); /*输入失败信息*/

return;

}

printf("\t\t\this(her) number:%s\n",stud[i].num); /*输出该学生信息*/

printf("\t\t\this(her) score:%d\n",stud[i].score);

}

void Statistic(Student stud[],int n) /*新增功能,输出统计信息*/

{ int i,j=0,k=0,sum=0;

float aver; /*成绩平均值*/

for(i=0;i
<n;i++) *循环输入判断*
{

sum+=stud[i].score;

if(stud[j].score>stud[i].score) j=i;

if(stud[k].score
<stud[i].score) k="i;"
}

aver=1.0*sum/n;

printf("\t\t\tthere are %d records.\n",n); /*总共记录数*/

printf("\t\t\tthe hignest score:\n"); /*最高分*/

printf("\t\t\tnumber:%s name:%s score:%d\n",stud[j].num,stud[j].name,stud[j].score);

printf("\t\t\tthe lowest score:\n"); /*最低分*/

printf("\t\t\tnumber:%s name:%s score:%d\n",stud[k].num,stud[k].name,stud[k].score);

printf("\t\t\tthe average score is %5.2f\n",aver); /*平均分*/

}

int AddfromText(Student stud[],int n) /*从文件中读入数据*/

{ int i=0,num;

FILE *fp; /*定义文件指针*/

char filename[20]; /*定义文件名*/

printf("\t\t\tInput the filename:");

scanf("\t\t\t%s",filename); /*输入文件名*/

if((fp=fopen(filename,"rb"))==NULL) /*打开文件*/

{ printf("\t\t\tcann't open the file\n"); /*打开失败信息*/

printf("\t\t\t");

system("pause");

return(n);

}

fscanf(fp,"%d",&num); /*读入总记录量*/

while(i
<num) *循环读入数据*
{

fscanf(fp,"%s%s%d",stud[n+i].num,stud[n+i].name,&stud[n+i].score);

i++;

}

n+=num;

fclose(fp); /*关闭文件*/

printf("\t\t\tSuccessed!\n");

printf("\t\t\t");

system("pause");

return(n);

}

void WritetoText(Student stud[],int n) /*将所有记录写入文件*/

{

int i=0;

FILE *fp; /*定义文件指针*/

char filename[20]; /*定义文件名*/

printf("\t\t\tWrite Records to a Text File\n"); /*输入文件名*/

printf("\t\t\tInput the filename:");

scanf("\t\t\t%s",filename);

if((fp=fopen(filename,"w"))==NULL) /*打开文件*/

{

printf("\t\t\tcann't open the file\n");

system("pause");

return;

}

fprintf(fp,"%d\n",n); /*循环写入数据*/

while(i
<n)
{

fprintf(fp,"%-16s%-15s%d\n",stud[i].num,stud[i].name,stud[i].score);

i++;

}

fclose(fp); /*关闭文件*/

printf("Successed!\n"); /*返回成功信息*/

}

void main() /*主函数*/

{

int n=0;

for(;;)

{

switch(menu_select()) /*选择判断*/

{

case 1:

printf("\t\t\tInput Records\n"); /*输入若干条记录*/

n=Input(stu,n);

break;

case 2:

printf("\t\t\tDisplay All Records\n"); /*显示所有记录*/

Display(stu,n);

break;

case 3:

printf("\t\t\tSort\n");

Sort_by_num(stu,n); /*按学号排序*/

printf("\t\t\tSort Suceessed!\n");

printf("\t\t\t");

system("pause");

break;

case 4:

printf("\t\t\tInsert a Record\n");

n=Insert_a_record(stu,n); /*插入一条记录*/

printf("\t\t\t");

system("pause");

break;

case 5:

printf("\t\t\tDelete a Record\n");

n=Delete_a_record(stu,n); /*按姓名查找,删除一条记录*/

printf("\t\t\t");

system("pause");

break;

case 6:

printf("\t\t\tQuery\n");

Query_a_record(stu,n); /*查找并显示一个记录*/

printf("\t\t\t");

system("pause");

break;

case 7:

printf("\t\t\tStatistic\n");

Statistic(stu,n); /*新增功能,输出统计信息*/

printf("\t\t\t");

system("pause");

break;

case 8:

printf("\t\t\tAdd Records from a Text File\n");

n=AddfromText(stu,n); /*新增功能,输出统计信息*/

break;

case 9:

printf("\t\t\tWrite to a Text file\n");

WritetoText(stu,n); /*循环写入数据*/

printf("\t\t\t");

system("pause");

break;

case 0:

printf("\t\t\tHave a Good Luck,Bye-bye!\n"); /*结束程序*/

printf("\t\t\t");

system("pause");

exit(0);

}

}

}

四、函数调用关系图

注:“→”代表调用

Input函数

打印链表记录

Display函数

输入若干条记录

menu_select()函数

选择菜单

Sort_by_num函数

显示所有记录

Delete_a_record函数

按姓名查找,删除一条记录

Query_a_record查找并显示一条记录

Statistic函数

输出统计信息 (新增)

AddfromText函数

从正文中添加数据到结构体数组中

Main函数

Insert_a_record插入一条记录

WritetoText函数 将所有数据写入文件中

退出程序

Reverse(head)函数

按学号排序

五、设计测试流程

1、进入界面

2、输入选项1,回车;

按提示输入数据:

3、回到主菜单;

输入选项7,回车;

输入文件名:data.txt,回车;

出现成功提示,则读入文件操作成功。

4、回到主菜单,输入2,回车

每10个暂停显示数据

5、回到主菜单,输入3,回车

出现排序成功信息。

6、回到主菜单,输入4,回车

按提示插入一组数据

7、回到主菜单,输入5,回车

按提示输入姓名,删除数据

出现删除成功的信息

8、回到主菜单,输入6,回车

输入姓名进行查询

9、回到主菜单,输入7,回车

出现统计信息

10、回到主菜单,输入9,回车

输入result.txt,回车

出现成功写入文件的信息

11、回到主菜单,输入0,回车退出系统

回答者:kingkey001 - 试用期 一级 7-14 22:38

修改答复: kingkey001,您要修改的答复如下: 积分规则 关闭

C语言课程设计报告-------学生成绩简单管理程序

一、系统菜单的主要功能

(1)输入若干条记录

(2)显示所有记录

(3)按学号排序

(4)插入一条记录

(5)按姓名查找,删除一条记录

(6)查找并显示一条记录

(7)输出统计信息 (新增)

(8)从正文中添加数据到结构体数组中

(9)将所有数据写入文件中

(0)退出程序

二、题目分析

该题主要考察学生对结构体,指针,文件的操作,以及C语言算法的掌握,所以完成此道题目要求较强的设计能力,尤其是要有一种大局观的意识。如何调程序也非常重要,通过这个程序可以学习到以前调试短程序没有的的经验。

菜单中的每一个选项都对应一个子程序,子程序的算法几乎囊获了所有C语言学过的技巧,下面就各个子程序中的功能进行说明:

功能1和4的算法相似,输入一条记录到结构体中去,其中有一部很关键,就是通过gets将所有的多余的字符,回车读去,否则就会出错。

功能2是显示所有的记录,通过循环输出,格式也比较重要。

功能3为按学号排序,因为学号定义成了字符数组的形式,因此在运用冒泡法进行排序的时候,要用到strcmp,strcpy等函数。

功能5为按姓名删除记录,先输入姓名,再一一比较,如果没有则返回失败信息,如果找到就将此记录都向前移一位,返回n-1。

功能6的算法在5中就已经体现了,输入姓名,一一比较。

功能7为新增的功能,因为考虑到原来给出的函数中竟然没有对学生成绩的统计功能,因此新增此功能,可以得出所有的记录个数,最高、最低、平均分,并输出相关的学生信息等。

功能8和9是对文件的操作,提前准备好数据。

三、程序正文部分

#include

/*引用库函数*/

#include

#include

#include

typedef struct /*定义结构体数组*/

{

char num[10]; /*学号*/

char name[20]; /*姓名*/

int score; /*成绩*/

}Student;

Student stu[80]; /*结构体数组变量*/

int menu_select() /*菜单函数*/

{

char c;

do{

system("cls"); /*运行前清屏*/

printf("\t\t****Students' Grade Management System****\n"); /*菜单选择*/

printf("\t\t | 1. Input Records |\n");

printf("\t\t | 2. Display All Records |\n");

printf("\t\t | 3. Sort |\n");

printf("\t\t | 4. Insert a Record |\n");

printf("\t\t | 5. Delete a Record |\n");

printf("\t\t | 6. Query |\n");

printf("\t\t | 7. Statistic |\n");

printf("\t\t | 8. Add Records from a Text File|\n");

printf("\t\t | 9. Write to a Text file |\n");

printf("\t\t | 0. Quit |\n");

printf("\t\t*****************************************\n");

printf("\t\t\tGive your Choice(0-9):");

c=getchar(); /*读入选择*/

}while(c<'0'||c>'9');

return(c-'0'); /*返回选择*/

}

int Input(Student stud[],int n) /*输入若干条记录*/

{int i=0;

char sign,x[10]; /*x[10]为清除多余的数据所用*/

while(sign!='n'&&sign!='N') /*判断*/

{ printf("\t\t\tstudent's num:"); /*交互输入*/

scanf("\t\t\t%s",stud[n+i].num);

printf("\t\t\tstudent's name:");

scanf("\t\t\t%s",stud[n+i].name);

printf("\t\t\tstudent's score:");

scanf("\t\t\t%d",&stud[n+i].score);

gets(x); /*清除多余的输入*/

printf("\t\t\tany more records?(Y/N)");

scanf("\t\t\t%c",&sign); /*输入判断*/

i++;

}

return(n+i);

}

void Display(Student stud[],int n) /*显示所有记录*/

{

int i;

printf("\t\t\t-----------------------------------\n"); /*格式头*/

printf("\t\t\tnumber name score\n");

printf("\t\t\t-----------------------------------\n");

for(i=1;i
<n+1;i++) *循环输入*
{

printf("\t\t\t%-16s%-15s%d\n",stud[i-1].num,stud[i-1].name,stud[i-1].score);

if(i>1&&i%10==0) /*每十个暂停*/

{printf("\t\t\t-----------------------------------\n"); /*格式*/

printf("\t\t\t");

system("pause");

printf("\t\t\t-----------------------------------\n");

}

}

printf("\t\t\t");

system("pause");

}

void Sort_by_num(Student stud[],int n) /*按学号排序*/

{ int i,j,*p,*q,s;

char t[10];

for(i=0;i
<n-1;i++) *冒泡法排序*
for(j=0;j
<n-1-i;j++)
if(strcmp(stud[j].num,stud[j+1].num)>0)

{strcpy(t,stud[j+1].num);

strcpy(stud[j+1].num,stud[j].num);

strcpy(stud[j].num,t);

strcpy(t,stud[j+1].name);

strcpy(stud[j+1].name,stud[j].name);

strcpy(stud[j].name,t);

p=&stud[j+1].score;

q=&stud[j].score;

s=*p;

*p=*q;

*q=s;

}

}

int Insert_a_record(Student stud[],int n) /*插入一条记录*/

{char x[10]; /*清除多余输入所用*/

printf("\t\t\tstudent's num:"); /*交互式输入*/

scanf("\t\t\t%s",stud[n].num);

printf("\t\t\tstudent's name:");

scanf("\t\t\t%s",stud[n].name);

printf("\t\t\tstudent's score:");

scanf("\t\t\t%d",&stud[n].score);

gets(x);

n++;

Sort_by_num(stud,n); /*调用排序函数*/

printf("\t\t\tInsert Successed!\n"); /*返回成功信息*/

return(n);

}

int Delete_a_record(Student stud[],int n) /*按姓名查找,删除一条记录*/

{ char s[20];

int i=0,j;

printf("\t\t\ttell me his(her) name:"); /*交互式问寻*/

scanf("%s",s);

while(strcmp(stud[i].name,s)!=0&&i
<n) i++; *查找判断*
if(i==n)

{ printf("\t\t\tnot find!\n"); /*返回失败信息*/

return(n);

}

for(j=i;j
<n-1;j++) *删除操作*
{

strcpy(stud[j].num,stud[j+1].num);

strcpy(stud[j].name,stud[j+1].name);

stud[j].score=stud[j+1].score;

}

printf("\t\t\tDelete Successed!\n"); /*返回成功信息*/

return(n-1);

}

void Query_a_record(Student stud[],int n) /*查找并显示一个记录*/

{ char s[20];

int i=0;

printf("\t\t\tinput his(her) name:"); /*交互式输入*/

scanf("\t\t\t%s",s);

while(strcmp(stud[i].name,s)!=0&&i
<n) i++; *查找判断*
if(i==n)

{ printf("\t\t\tnot find!\n"); /*输入失败信息*/

return;

}

printf("\t\t\this(her) number:%s\n",stud[i].num); /*输出该学生信息*/

printf("\t\t\this(her) score:%d\n",stud[i].score);

}

void Statistic(Student stud[],int n) /*新增功能,输出统计信息*/

{ int i,j=0,k=0,sum=0;

float aver; /*成绩平均值*/

for(i=0;i
<n;i++) *循环输入判断*
{

sum+=stud[i].score;

if(stud[j].score>stud[i].score) j=i;

if(stud[k].score
<stud[i].score) k="i;
}

aver=1.0*sum/n;

printf("\t\t\tthere are %d records.\n",n); /*总共记录数*/

printf("\t\t\tthe hignest score:\n"); /*最高分*/

printf("\t\t\tnumber:%s name:%s score:%d\n",stud[j].num,stud[j].name,stud[j].score);

printf("\t\t\tthe lowest score:\n"); /*最低分*/

printf("\t\t\tnumber:%s name:%s score:%d\n",stud[k].num,stud[k].name,stud[k].score);

printf("\t\t\tthe average score is %5.2f\n",aver); /*平均分*/

}

int AddfromText(Student stud[],int n) /*从文件中读入数据*/

{ int i=0,num;

FILE *fp; /*定义文件指针*/

char filename[20]; /*定义文件名*/

printf("\t\t\tInput the filename:");

scanf("\t\t\t%s",filename); /*输入文件名*/

if((fp=fopen(filename,"rb"))==NULL) /*打开文件*/

{ printf("\t\t\tcann't open the file\n"); /*打开失败信息*/

printf("\t\t\t");

system("pause");

return(n);

}

fscanf(fp,"%d",&num); /*读入总记录量*/

while(i
<num) *循环读入数据*
{

fscanf(fp,"%s%s%d",stud[n+i].num,stud[n+i].name,&stud[n+i].score);

i++;

}

n+=num;

fclose(fp); /*关闭文件*/

printf("\t\t\tSuccessed!\n");

printf("\t\t\t");

system("pause");

return(n);

}

void WritetoText(Student stud[],int n) /*将所有记录写入文件*/

{

int i=0;

FILE *fp; /*定义文件指针*/

char filename[20]; /*定义文件名*/

printf("\t\t\tWrite Records to a Text File\n"); /*输入文件名*/

printf("\t\t\tInput the filename:");

scanf("\t\t\t%s",filename);

if((fp=fopen(filename,"w"))==NULL) /*打开文件*/

{

printf("\t\t\tcann't open the file\n");

system("pause");

return;

}

fprintf(fp,"%d\n",n); /*循环写入数据*/

while(i
<n)
{

fprintf(fp,"%-16s%-15s%d\n",stud[i].num,stud[i].name,stud[i].score);

i++;

}

fclose(fp); /*关闭文件*/

printf("Successed!\n"); /*返回成功信息*/

}

void main() /*主函数*/

{

int n=0;

for(;;)

{

switch(menu_select()) /*选择判断*/

{

case 1:

printf("\t\t\tInput Records\n"); /*输入若干条记录*/

n=Input(stu,n);

break;

case 2:

printf("\t\t\tDisplay All Records\n"); /*显示所有记录*/

Display(stu,n);

break;

case 3:

printf("\t\t\tSort\n");

Sort_by_num(stu,n); /*按学号排序*/

printf("\t\t\tSort Suceessed!\n");

printf("\t\t\t");

system("pause");

break;

case 4:

printf("\t\t\tInsert a Record\n");

n=Insert_a_record(stu,n); /*插入一条记录*/

printf("\t\t\t");

system("pause");

break;

case 5:

printf("\t\t\tDelete a Record\n");

n=Delete_a_record(stu,n); /*按姓名查找,删除一条记录*/

printf("\t\t\t");

system("pause");

break;

case 6:

printf("\t\t\tQuery\n");

Query_a_record(stu,n); /*查找并显示一个记录*/

printf("\t\t\t");

system("pause");

break;

case 7:

printf("\t\t\tStatistic\n");

Statistic(stu,n); /*新增功能,输出统计信息*/

printf("\t\t\t");

system("pause");

break;

case 8:

printf("\t\t\tAdd Records from a Text File\n");

n=AddfromText(stu,n); /*新增功能,输出统计信息*/

break;

case 9:

printf("\t\t\tWrite to a Text file\n");

WritetoText(stu,n); /*循环写入数据*/

printf("\t\t\t");

system("pause");

break;

case 0:

printf("\t\t\tHave a Good Luck,Bye-bye!\n"); /*结束程序*/

printf("\t\t\t");

system("pause");

exit(0);

}

}

}

四、函数调用关系图

注:“→”代表调用

Input函数

打印链表记录

Display函数

输入若干条记录

menu_select()函数

选择菜单

Sort_by_num函数

显示所有记录

Delete_a_record函数

按姓名查找,删除一条记录

Query_a_record查找并显示一条记录

Statistic函数

输出统计信息 (新增)

AddfromText函数

从正文中添加数据到结构体数组中

Main函数

Insert_a_record插入一条记录

WritetoText函数 将所有数据写入文件中

退出程序

Reverse(head)函数

按学号排序

五、设计测试流程

1、进入界面

2、输入选项1,回车;

按提示输入数据:

3、回到主菜单;

输入选项7,回车;

输入文件名:data.txt,回车;

出现成功提示,则读入文件操作成功。

4、回到主菜单,输入2,回车

每10个暂停显示数据

5、回到主菜单,输入3,回车

出现排序成功信息。

6、回到主菜
</n)

</n-1-i;j++)

VB简易日历课程设计(任务书如下)

可以制作 ···需要的话百度hi我··· 已经完成··联系我好了··
Option Explicit
Dim xuanzedate%
Private Sub Form_Load()
xuanzedate% = CInt(Format$(Now, "dd"))
Call tianchongbn01
Call tianchongbn02
Call setdate
Dim r%, week$
r% = Weekday(Format$(Now, "general date"))
If r% = 1 Then
week$ = "星期日"
ElseIf r% = 2 Then
week = "星期一"
ElseIf r% = 3 Then
week = "星期二"
ElseIf r% = 4 Then
week = "星期三"
ElseIf r% = 5 Then
week = "星期四"
ElseIf r% = 6 Then
week = "星期五"
Else
week = "星期六"
End If
bn002.Text = week$
bn001.Text = Format$(Now, "yyyy" & "年" & "m" & "月" & "d" & "日")
End Sub
Private Sub checkdate(month%, year%)
Dim i%, value%, datebn$
For i% = 28 To 32
datebn$ = (Str$(month%) + "/" + Str$(i%) + "/" + Str$(year%))
If IsDate(datebn$) Then
value% = i%
Else
Call visualnumber(value%)
Exit Sub
End If
Next i%
End Sub
Private Sub setdate()
Dim r%, i%
r% = CInt(Format$(Now, "yyyy"))
i% = r% - 1960
bn02.ListIndex = i%
r% = CInt(Format$(Now, "mm"))
bn01.ListIndex = (r% - 1)
r% = CInt(Format$(Now, "dd"))
bndate(r% - 1).BorderStyle = 1
xuanzedate% = r%
End Sub
Private Sub tianchongbn01()
bn01.AddItem "一月"
bn01.AddItem "二月"
bn01.AddItem "三月"
bn01.AddItem "四月"
bn01.AddItem "五月"
bn01.AddItem "六月"
bn01.AddItem "七月"
bn01.AddItem "八月"
bn01.AddItem "九月"
bn01.AddItem "十月"
bn01.AddItem "十一月"
bn01.AddItem "十二月"
End Sub
Private Sub tianchongbn02()
Dim i%
For i% = 1960 To 2060
bn02.AddItem Str$(i%)
Next i%
End Sub
Private Sub bn01_click()
Call setday
Call bndate_click(xuanzedate% - 1)
End Sub
Private Sub bn02_Click()
Static abc%
If Not abc Then
abc = True
Exit Sub
End If
Call bn01_click
End Sub
Private Sub setday()
Dim month%, year%
month% = setmonth()
year% = setyear()
Call checkdate(month%, year%)
End Sub
Private Sub bndate_click(Index As Integer)
Dim i%
On Error GoTo err1
For i% = 0 To 30
bndate(i%).BorderStyle = 0
Next i%
If bndate(Index).BorderStyle = 1 Then
bndate(Index).BorderStyle = 0
Else
bndate(Index).BorderStyle = 1
End If
xuanzedate% = Index + 1
Dim month%, day%, year%, datebn$
day% = xuanzedate%
month% = bn01.ListIndex + 1
year% = bn02.ListIndex + 1960
datebn$ = (Str$(month%) + "/" + Str$(day%) + "/" + Str$(year%))
If bn01.Text = "九月" And bndate(11).BorderStyle = 1 Then
MsgBox "老师好,欢迎您检阅我的设计。 题目是简易日历。今天是08年6月23号。我是材料````。", , "欢迎:>"
ElseIf bn01.Text = "九月" And bndate(12).BorderStyle = 1 Then
MsgBox "老师好,欢迎您检阅我的设计。 题目是简易日历。今天是08年6月23号。我是材料````。", , "欢迎:>"
End If
Dim r%
Dim week$
r% = Weekday(datebn$)
If r% = 1 Then
week$ = "星期日"
ElseIf r% = 2 Then
week = "星期一"
ElseIf r% = 3 Then
week = "星期二"
ElseIf r% = 4 Then
week = "星期三"
ElseIf r% = 5 Then
week = "星期四"
ElseIf r% = 6 Then
week = "星期五"
Else
week = "星期六"
End If
bn002.Text = week$
bn001.Text = Format$(datebn$, "long date")
err1:
If Err = 0 Then Exit Sub
If Err = 13 Then
xuanzedate% = xuanzedate% - 1
Exit Sub
End If
End Sub
Private Function setmonth%()
Dim i%
i% = bn01.ListIndex
setmonth% = i% + 1
End Function
Private Function setyear%()
Dim i%
i% = bn02.ListIndex
If i% = -1 Then Exit Function
setyear% = CInt(Trim(bn02.List(i%)))
End Function
Private Sub visualnumber(number%)
Dim i%
For i% = 28 To 30
bndate(i%).Visible = False
Next i%
For i% = 28 To number% - 1
bndate(i%).Visible = True
Next i%
End Sub
Private Sub bnyes_Click()
Dim month%, day%, year%, datebn$
day% = xuanzedate%
month% = bn01.ListIndex + 1
year% = bn02.ListIndex + 1960
datebn$ = (Str$(month%) + "/" + Str$(day%) + "/" + Str$(year%))
datebn$ = Format$(datebn$, "general date")
MsgBox Format$(datebn$, "long date"), , "您选定的日期为:"
If bn01.Text = "十月" And bndate(0).BorderStyle = 1 Then
MsgBox "国庆节快乐", , "节日/纪念日"
ElseIf bn01.Text = "二月" And bndate(13).BorderStyle = 1 Then
MsgBox "情人节快乐:>", , "节日/纪念日"
ElseIf bn01.Text = "一月" And bndate(0).BorderStyle = 1 Then
MsgBox "元旦快乐,又一年了,加油啊", , "节日/纪念日"
ElseIf bn01.Text = "三月" And bndate(11).BorderStyle = 1 Then
MsgBox "植树节了,心系环保", , "节日/纪念日"
ElseIf bn01.Text = "四月" And bndate(0).BorderStyle = 1 Then
MsgBox "愚人节的小傻瓜们,今天被骗了没?:-P", , "节日/纪念日"
ElseIf bn01.Text = "六月" And bndate(0).BorderStyle = 1 Then
MsgBox "儿童节快乐,有颗童心会更加快乐!", , "节日/纪念日"
ElseIf bn01.Text = "八月" And bndate(0).BorderStyle = 1 Then
MsgBox "建军节快乐", , "节日/纪念日"
ElseIf bn01.Text = "十二月" And bndate(24).BorderStyle = 1 Then
MsgBox "圣诞节快乐", , "节日/纪念日"
ElseIf bn01.Text = "三月" And bndate(7).BorderStyle = 1 Then
MsgBox "妇女节快乐", , "节日/纪念日"
End If
End Sub
Private Sub bnexit_Click()
Unload Me
End Sub

阅读更多 >>>  vb编程语言入门,自学vb语言的方法有哪些?

五子棋游戏程序设计(VB)

  五子棋的AI构想   有句话叫“当局者迷,旁观者清。”,但这句话在由AI所控制的计算机玩家上是不成立的,因为计算机必须知道有那些获胜方式,并计算出每下一步棋到棋盘上任一格子的获胜几率,也就是说,一个完整的五子棋的AI构想必须:
 
  1、能够知道所有的获胜组合;   2、建立和使用获胜表;   3、设定获胜的分数;   4、使电脑具有攻击和防守的能力;   一、求五子棋的获胜组合   在一场五子棋的游戏中,计算机必须要知道有那些的获胜组合,因此我们必须求得获胜组合的总数。我们假定当前的棋盘为10*10。   (1)计算水平方向的获胜组合数,每一列的获胜组合是:6,共10列,所以水平方向的获胜组合数为:6*10=60   (2)计算垂直方向的获胜组合总数,每一行的获胜组合是:6,共10行,则垂直方向的获胜组合数为:6*10=60   (3)计算正对角线方向的获胜组合总数,正对角线上的获胜组合总数为6+(5+4+3+2+1)*2=36   (4)计算反对角线方向的获胜组合总数,反对角线上的获胜组合总数为6+(5+4+3+2+1)*2=36 ,这样所有的获胜组合数为:60+60+36+36=192   二、建立和使用获胜表   我们已经计算出了一个10*10的五子棋盘会有192种获胜方式,这样我们可以利用数组建立获胜表,获胜表的主要作用是:1,判断当前的获胜方式是否有效;2,判断当前的获胜方式中到底有多少子落入该获胜组合中。详细的使用您将在后面的程序中可以看出。   三,分数的设定   在游戏中为了让计算机能够决定下一步最佳的走法,必须先计算出计算机下到棋盘上任一空格的分数,而其中最高分数便是计算机下一步的最佳走法。   原理:我们判定当前讨论的空格与当前讨论的点有几种获胜的方式,有几种该空格就加几分。这种原理初听起来似乎是无法入手,没关系,当您了解我们后面的程序后您就会明白这种决策原理了。   这种决策有一些缺陷,因为如果只根据这个模型设计,就有可能出现电脑或玩家有三个子连成一线的时候,计算机却判断不出,它认为其他某些空格是当前的获胜的最佳位置而不去攻击或防守。没关系我们完全可以通过一个加强算法来改变当前的分值情况,也就是说当电脑或玩家有三个子或四个子连成一线时,我们通过加强算法将当前与三个子或四个子有关的空格的分值提高,从而可以弥补这一缺憾。   四、攻击与防守   以上的方式,事实上计算机只是计算出了最佳的攻击位置,为了防守我们还应计算当前玩家的最佳的攻击位置。这样有什么用呢?道理很简单,如果玩家最佳攻击位置的分数大于计算机最佳攻击位置上的分数,那么计算机就将下一步的棋子摆在玩家的最佳攻击位上以阻止玩家的进攻,否则计算机便将棋子下在自己的最佳攻击位置上进行攻击。   事实上,这个AI构想是很强大的如果你不是很厉害的五子棋高手的话,可能很快会被计算机打败。我在联众上可是中级棋手啊,跟这种构想打的时候胜率也不是很高。 使用vb.net编写五子棋   一、编写前的准备:   1、用计算机的思想描述整个下棋的过程   考虑步骤:   (1)为了简便我们可以先让电脑先走第一步棋,电脑每走一步就会封掉许多玩家的获胜可能情况。   (2)当玩家走棋的时候我们首先应该考虑玩家走棋的合法性。   (3)如果合法,那么玩家也会封掉许多电脑的获胜的可能情况。   (4)电脑的思考路径:首先判断当前玩家和电脑的所有获胜组合是否需要进行加强赋值,
是进行加强赋值,否则进行普通的赋值。   (5)比较当前玩家和电脑谁的分值最大。将分值最大的点作为电脑的下一步走法。   2、利用vb.net窗体和图形工具建立五子棋的棋盘界面   (1)添加一个picturebox控件   作用:使用picturebox控件绘制棋子和棋盘   (2)添加一个label控件   作用:显示当前的获胜标志,也就是当某一方获胜或和棋时显示此标签。   (3)添加一个mainmenu控件   作用:控制游戏的开始或结束   (4)添加一个mediaplay组件   作用:使程序可以播放音乐。   3、设置整体框价   我们采取10*10的棋盘,为主要的平台。利用数组定义整个棋盘桌面,利用数组定义获胜组合以及获胜标志等。   二,声明全局数组和变量   定义虚拟桌面: Dim table(9, 9) As Integer   定义当前玩家桌面空格的分数: Dim pscore(9, 9) As Integer   定义当前电脑桌面空格的分数: Dim cscore(9, 9) As Integer   定义玩家的获胜组合: Dim pwin(9, 9, 191) As Boolean   定义电脑的获胜组合: Dim cwin(9, 9, 191) As Boolean   定义玩家的获胜组合标志: Dim pflag(191) As Boolean   定义电脑的获胜组合标志:
Dim cflag(191) As Boolean   定义游戏有效标志: Dim theplayflag As Boolean 三、初始化游戏 '*****************************************************************************
'** 模块名称: initplayenvironment
'**
'** 描述: 此函数主要功能如下:
'** 1. 设置背景音乐。
'** 2. 设置游戏状态有效。
'** 3. 初始化游戏状态标签。
'** 4. 直接指定电脑的第一步走法。
'** 5. 初始化基本得分桌面。
'** 6. 电脑和玩家获胜标志初始化。
'** 7. 初始化所有获胜组合。
'** 8. 重新设定玩家的获胜标志。
'**
'*****************************************************************************
Sub initplayenvironment()
player.FileName = ".\music\zhyu01.mid"
player.Play()
theplayflag = True
'游戏有效
Label1.Visible = False
'游戏状态标签不显示
PictureBox1.Refresh()
'清空picturebox1的内容
yuandian(130, 130)
'调用绘图函数绘制当前电脑先走的位置
Dim i, j, m, n As Integer
For i = 0 To 9
For j = 0 To 9
table(i, j) = 0
Next
Next
'桌面初始化
For i = 0 To 191
pflag(i) = True
cflag(i) = True
Next
'获胜标志初始化
table(4, 4) = 1
'由于我们设定电脑先手,并下了4,4位所以将其值设为1
''' ******** 初始化获胜组合 ********
n = 0
For i = 0 To 9
For j = 0 To 5
For m = 0 To 4
pwin(j + m, i, n) = True
cwin(j + m, i, n) = True
Next
n = n + 1
Next
Next
For i = 0 To 9
For j = 0 To 5
For m = 0 To 4
pwin(i, j + m, n) = True
cwin(i, j + m, n) = True
Next
n = n + 1
Next
Next
For i = 0 To 5
For j = 0 To 5
For m = 0 To 4
pwin(j + m, i + m, n) = True
cwin(j + m, i + m, n) = True
Next
n = n + 1
Next
Next
For i = 0 To 5
For j = 9 To 4 Step -1
For m = 0 To 4
pwin(j - m, i + m, n) = True
cwin(j - m, i + m, n) = True
Next
n = n + 1
Next
Next
''' ******** 初始化获胜组合结束 ********
For i = 0 To 191
If pwin(4, 4, i) = True Then
pflag(i) = False
End If
Next
'由于电脑已下了4,4位所以我们需要重新设定玩家的获胜标志
End Sub
四,处理鼠标事件 '*****************************************************************************
'** 模块名称: themousedown
'**
'** 描述: 此函数主要实行以下功能:
'** 1. 判定当前游戏标志是否有效。
'** 2. 将实际坐标转化成虚拟坐标。
'** 3. 绘制玩家的棋子。
'** 4. 执行检查获胜函数。
'** 5. 执行电脑算法函数。
'**
'*****************************************************************************
Sub themousedown(ByVal x As Integer, ByVal y As Integer)
If theplayflag = False Then
Exit Sub
End If
'检查游戏状态是否有效
Dim i, j As Integer
Dim zhx, zhy As Integer
zhx = Int((x - 10) / 30)
zhy = Int((y - 10) / 30)
For i = 0 To 9
For j = 0 To 9
If table(zhx, zhy) > 0 Then
Exit Sub
End If
Next
Next
'检查当前鼠标点击的格子是否有效
Dim mycolor As Color
Dim g As System.Drawing.Graphics
g = PictureBox1.CreateGraphics
mycolor = Color.White
Dim brush1 As System.Drawing.Brush = New SolidBrush(mycolor)
g.FillEllipse(brush1, zhx * 30 + 10, zhy * 30 + 10, 30, 30)
'绘制玩家的棋子
table(zhx, zhy) = 2
For i = 0 To 191
If cwin(zhx, zhy, i) = True Then
cflag(i) = False
End If
Next
'重设电脑的获胜标志
checkwin()
'检查当前玩家是否获胜
diannao()
'调用电脑算法
End Sub   五、获胜检查算法。 '*****************************************************************************
'** 模块名称: checkwin
'**
'** 描述: 此模块执行以下功能:
'** 1. 检查是否和棋。
'** 2. 检查电脑是否获胜。
'** 3. 检查玩家是否获胜。
'**
'*****************************************************************************
Sub checkwin()
Dim i, j, k, m, n As Integer
Dim ca As Integer
Dim pa As Integer
Dim cnormal As Integer = 0
For i = 0 To 191
If cflag(i) = False Then
cnormal = cnormal + 1
End If
Next
If cnormal = 190 Then
Label1.Visible = True
Label1.Text = "和棋,请重新开始!"
PictureBox1.Refresh()
theplayflag = False
Exit Sub
End If
'设定和棋规则
For i = 0 To 191
If cflag(i) = True Then
ca = 0
For j = 0 To 9
For k = 0 To 9
If table(j, k) = 1 Then
If cwin(j, k, i) = True Then
ca = ca + 1
End If
End If
Next
Next
If ca = 5 Then
Label1.Visible = True
Label1.Text = "电脑获胜,请重新开始"
PictureBox1.Refresh()
theplayflag = False
Exit Sub
End If
End If
Next
'检查电脑是否获胜
For i = 0 To 191
If pflag(i) = True Then
pa = 0
For j = 0 To 9
For k = 0 To 9
If table(j, k) = 2 Then
If pwin(j, k, i) = True Then
pa = pa + 1
End If
End If
Next
Next
If pa = 5 Then
Label1.Visible = True
Label1.Text = "玩家获胜,请重新开始"
PictureBox1.Refresh()
theplayflag = False
Exit Sub
End If
End If
Next
'检查玩家是否获胜
End Sub  六、电脑算法 '*****************************************************************************
'** 模块名称: diannao
'**
'** 描述: 此程序主要执行以下功能:
'** 1. 初始化赋值系统。
'** 2. 赋值加强算法。
'** 3. 计算电脑和玩家的最佳攻击位。
'** 4. 比较电脑和玩家的最佳攻击位并决定电脑的最佳策略。
'** 5. 执行检查获胜函数。
'**
'***************************************************************************** Sub diannao()
Dim i, j, k, m, n As Integer
Dim dc As Integer
Dim cab As Integer
Dim pab As Integer
For i = 0 To 9
For j = 0 To 9
pscore(i, j) = 0
cscore(i, j) = 0
Next
Next
'初始化赋值数组
''' ******** 电脑加强算法 ********
For i = 0 To 191
If cflag(i) = True Then
cab = 0
For j = 0 To 9
For k = 0 To 9
If table(j, k) = 1 Then
If cwin(j, k, i) = True Then
cab = cab + 1
End If
End If
Next
Next
Select Case cab
Case 3
For m = 0 To 9
For n = 0 To 9
If table(m, n) = 0 Then
If cwin(m, n, i) = True Then
cscore(m, n) = cscore(m, n) + 5
End If
End If
Next
Next
Case 4
For m = 0 To 9
For n = 0 To 9
If table(m, n) = 0 Then
If cwin(m, n, i) = True Then
yuandian(m * 30 + 10, n * 30 + 10)
table(m, n) = 1
For dc = 0 To 191
If pwin(m, n, dc) = True Then
pflag(dc) = False
checkwin()
Exit Sub
End If
Next
End If
End If
Next
Next
End Select
End If
Next
For i = 0 To 191
If pflag(i) = True Then
pab = 0
For j = 0 To 9
For k = 0 To 9
If table(j, k) = 2 Then
If pwin(j, k, i) = True Then
pab = pab + 1
End If
End If
Next
Next
Select Case pab
Case 3
For m = 0 To 9
For n = 0 To 9
If table(m, n) = 0 Then
If pwin(m, n, i) = True Then
pscore(m, n) = pscore(m, n) + 30
End If
End If
Next
Next
Case 4
For m = 0 To 9
For n = 0 To 9
If table(m, n) = 0 Then
If pwin(m, n, i) = True Then
yuandian(m * 30 + 10, n * 30 + 10)
table(m, n) = 1
For dc = 0 To 191
If pwin(m, n, dc) = True Then
pflag(dc) = False
checkwin()
Exit Sub
End If
Next
End If
End If
Next
Next
End Select
End If
Next
''' ******** 电脑加强算法结束 ******** ' ******** 赋值系统 ********
For i = 0 To 191
If cflag(i) = True Then
For j = 0 To 9
For k = 0 To 9
If table(j, k) = 0 Then
If cwin(j, k, i) = True Then
For m = 0 To 9
For n = 0 To 9
If table(m, n) = 1 Then
If cwin(m, n, i) = True Then
cscore(j, k) = cscore(j, k) + 1
End If
End If
Next
Next
End If
End If
Next
Next
End If
Next
For i = 0 To 191
If pflag(i) = True Then
For j = 0 To 9
For k = 0 To 9
If table(j, k) = 0 Then
If pwin(j, k, i) = True Then
For m = 0 To 9
For n = 0 To 9
If table(m, n) = 2 Then
If pwin(m, n, i) = True Then
pscore(j, k) = pscore(j, k) + 1
End If
End If
Next
Next
End If
End If
Next
Next
End If
Next
''' ******** 赋值系统结束 ********
''' ******** 分值比较算法 ********
Dim a, b, c, d As Integer
Dim cs As Integer = 0
Dim ps As Integer = 0
For i = 0 To 9
For j = 0 To 9
If cscore(i, j) > cs Then
cs = cscore(i, j)
a = i
b = j
End If
Next
Next
For i = 0 To 9
For j = 0 To 9
If pscore(i, j) > ps Then
ps = pscore(i, j)
c = i
d = j
End If
Next
Next
If cs > ps Then
yuandian(a * 30 + 10, b * 30 + 10)
table(a, b) = 1
For i = 0 To 191
If pwin(a, b, i) = True Then
pflag(i) = False
End If
Next
Else
yuandian(c * 30 + 10, d * 30 + 10)
table(c, d) = 1
For i = 0 To 191
If pwin(c, d, i) = True Then
pflag(i) = False
End If
Next
End If
''' ******** 分值比较算法结束 ********
checkwin()
End Sub   七、绘制棋子 '*****************************************************************************
'** 模块名称: yuandian
'**
'** 描述: 此函数主要进行电脑棋子的绘制。
'**
'***************************************************************************** Sub yuandian(ByVal x As Integer, ByVal y As Integer)
Dim mycolor As Color
Dim g As System.Drawing.Graphics
g = PictureBox1.CreateGraphics
Dim zhx, zhy As Integer
zhx = Int((x - 10) / 30)
zhy = Int((y - 10) / 30)
mycolor = Color.Black
Dim brush1 As System.Drawing.Brush = New SolidBrush(mycolor)
g.FillEllipse(brush1, zhx * 30 + 10, zhy * 30 + 10, 30, 30)
End Sub

阅读更多 >>>  vb编程软件,windows visual basic是什么软件,怎么用

vb课程设计~~~代码已有求解释~~~~越详细越好~~大神们来啊~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

你也太牛B了吧,还叫别人去访问一下你的空间!
Dim bln1 As Boolean
Dim bln2 As Boolean
Dim bln3 As Boolean
Dim bln4 As Boolean
Dim blnstoptuzi As Boolean
Dim blnstopwugui As Boolean
Dim int1 As Integer
Dim int2 As Integer
Dim int3 As Integer
Dim m As Integer
Dim n As Integer
Dim k As Integer '上面都是声明变量
Private Sub HScroll1_change() 'change当控件内容发送变化时的事件
k = CInt(HScroll1.Value) ‘cint 取整函数将内容赋予给变量k
Picture1.SetFocus '将焦点转到Picture控件
End Sub
Private Sub command1_Click()
Call 开始 '调用“开始”过程
End Sub
Private Sub menuaboutjog_Click() '这个应该是菜单的吧...
Dim intresponse As Integer
intresponse = MsgBox("版本1.01," & Chr(10) & Chr(13) & "欢迎多多指教!", 48, "关于龟兔赛跑") 'msgbox 函数弹出内容并赋予给变量intresponse
End Sub
Private Sub menuesc_Click()
Dim intresponse As Integer
intresponse = MsgBox("确定退出?", 289, "注意")
If intresponse = 1 Then '当用户按“确定”时卸载FORM1窗体
Unload Form1
End If
End Sub
Private Sub menuselffile_Click()
Shell "E:\5 游戏设计\26 龟兔赛跑\readme.txt", 1 'shell函数调用txt文本
End Sub
Private Sub menustart_Click()
Call 开始
End Sub
Private Sub Picture1_keypress(keyascii As Integer) 'picture的键盘事件
Dim blnxidongtuzi As Boolean
Dim intresponse As Integer
Dim a As Integer
If blnstoptuzi = True Then 'if语句 当blnstoptuzi为真时
If bln1 Or bln2 = False Then '当bln1 或 bln2 为假时
bln1 = False
bln2 = False “bln1和Bln2为假
End If
End If
If Image2.Left >= Picture1.Width - Image2.Width Then '当image2的left属性大于或等于picture的宽度减image2的宽度时
blnstoptuzi = True 'blnstoptuzi 为真
End If
If keyascii = 97 Then bln1 = True '当用户按下chr(97)时 bln1等于真,这里的97是ascii值我也记不住那么多你自己可以查 chr(ascii的值)就可以看到是哪个键了
If keyascii = 115 Then bln2 = True
If bln1 = False Then bln2 = False
If bln1 And bln2 = True Then
blnxidongtuzi = True
If blnxidongtuzi = True Then
Image2.Left = Image2.Left + k 'image2的left在'image2的left基础上加上变量k
blnxidongtuzi = False
bln1 = False
bln2 = False
End If
If (keyascii = 97 Or keyascii = 115) And int1 <= 7 Then
Image2.Left = 0
intresponse = MsgBox("兔选手抢跑,重来!", 16, "犯规!")
If intresponse = 1 Then
Timer1.Enabled = False
Label5.Caption = ""
End If
End If
End If
End Sub
Private Sub form_keypress(keyascii As Integer)
Dim blnxidongwugui As Boolean
Dim intresponse As Integer
If blnstopwugui = True Then
If bln3 Or bln4 = False Then
bln3 = False
bln4 = False
End If
End If
If Image3.Left >= Picture2.Width - Image3.Width Then
blnstopwugui = True
End If
If keyascii = 59 Then bln3 = True
If keyascii = 39 Then bln4 = True
If bln3 = False Then bln4 = False
If bln3 And bln4 = True Then
blnxidongwugui = True
If blnxidongwugui = True Then
Image3.Left = Image3.Left + k
blnxidongwugui = False
bln3 = False
bln4 = False
End If
If (keyascii = 59 Or 39) And int1 <= 7 Then
Image3.Left = 0
intresponse = MsgBox("龟选手抢跑,重来!", 16, "犯规!")
If intresponse = 1 Then
Timer1.Enabled = False
Label5.Caption = ""
End If
End If
End If
End Sub
Private Sub Timer1_Timer()
int1 = int1 + 1
If intl <= 6 And int1 Mod 2 = 0 Then
Label5.Caption = "预备!"
End If
If int1 <= 6 And int1 Mod 2 = 1 Then
Label5.Caption = ""
End If
If int1 = 7 Then
Label5.Caption = "开始!"
End If
If int1 >= 8 Then
Label5.Caption = ""
Timer1.Enabled = False
Timer2.Enabled = True
Timer3.Enabled = True
End If
End Sub
Private Sub Timer2_Timer()
Dim a As Integer
Dim b As Integer
a = int2 / 60
b = int2 Mod 60
int2 = int2 + 1
If int2 < 60 Then
If int2 < 10 Then
Text1.Text = "00:00:0" & int2
Else
Text1.Text = "00:00:" & int2
End If
Else
If b < 10 Then
Text1.Text = "00:00:0" & a
Else
Text1.Text = "00:00:" & a
End If
End If
If blnstoptuzi = True Then
Timer2.Enabled = False
Timer4.Enabled = True
m = int2
End If
End Sub
Private Sub Timer3_Timer()
Dim c As Integer
Dim d As Integer
c = int3 / 60
d = int3 Mod 60
int3 = int3 + 1
If int3 < 60 Then
If int3 < 10 Then
Text2.Text = "00:00:0" & int3
Else
Text2.Text = "00:00:" & int3
End If
Else
If d < 10 Then
Text2.Text = "00:00:0" & c
Else
Text2.Text = "00:00:" & c
End If
End If
If blnstopwugui = True Then
Timer3.Enabled = False
Timer4.Enabled = True
n = int3
End If
End Sub
Private Sub 开始()
If int1 <> 0 Or int2 <> 0 Then
Image2.Left = 0
Image3.Left = 0
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Text1.Text = "00:00:00"
Text2.Text = "00:00:00"
Label5.Caption = ""
int1 = 0
int2 = 0
int3 = 0
m = 0
n = 0
blnstoptuzi = False
blnstopwugui = False
Picture1.SetFocus
End If
Timer1.Enabled = True
End Sub
Private Sub Timer4_Timer()
Dim blnjs As Boolean
If m <> 0 And n <> 0 Then
blnjs = True
End If
If blnjs = True Then
If m < n Then
intresponse = MsgBox("兔选手赢了!", 48, "龟兔赛跑")
intresponse = 1
Timer2.Enabled = False
Timer3.Enabled = False
int2 = 0
int3 = 0
blnjs = False
End If
If m > n Then
intresponse = MsgBox("龟选手赢了!", 48, "龟兔赛跑")
intresponse = 1
Timer2.Enabled = False
Timer3.Enabled = False
int2 = 0
int3 = 0
blnjs = False
End If
End If
If blnjs = False Then
Timer4.Enabled = False
End If
End Sub
rme 意思基本上都差不多你可以自己看下吧

急求vb课程设计”直线拟合”的源代码

Form1 Private Sub Command1_Click() '显示第二个窗体Form1.HideForm2.ShowForm3.Hidezxnh = MsgBox("你必须完全输入所选的项目!" & Chr(10) & Chr(13) & _ "否则程序将会出错!", 48, "直线拟合")End Sub Private Sub Command2_Click() '结束程序EndEnd Sub '使第二个窗体的文本框按照第一个窗体给出的数据组数显示Private Sub Option1_Click()Form2.Label6.Enabled = FalseForm2.Label7.Enabled = FalseForm2.Label8.Enabled = FalseForm2.Label9.Enabled = FalseForm2.Label10.Enabled = FalseFor n = 6 To 10 Form2.Text1(n).Enabled = False Form2.Text1(n).BackColor = &H8000000F Form2.Text2(n).Enabled = False Form2.Text2(n).BackColor = &H8000000FNextEnd Sub Private Sub Option2_Click()Form2.Label6.Enabled = TrueForm2.Label7.Enabled = FalseForm2.Label8.Enabled = FalseForm2.Label9.Enabled = FalseForm2.Label10.Enabled = FalseForm2.Text1(6).Enabled = TrueForm2.Text1(6).BackColor = &HFFFFFFForm2.Text2(6).Enabled = TrueForm2.Text2(6).BackColor = &HFFFFFFFor n = 7 To 10 Form2.Text1(n).Enabled = False Form2.Text1(n).BackColor = &H8000000F Form2.Text2(n).Enabled = False Form2.Text2(n).BackColor = &H8000000FNextEnd Sub Private Sub Option3_Click()Form2.Label6.Enabled = TrueForm2.Label7.Enabled = TrueForm2.Label8.Enabled = FalseForm2.Label9.Enabled = FalseForm2.Label10.Enabled = FalseFor n = 6 To 7 Form2.Text1(n).Enabled = True Form2.Text1(n).BackColor = &HFFFFFF Form2.Text2(n).Enabled = True Form2.Text2(n).BackColor = &HFFFFFFNext For n = 8 To 10 Form2.Text1(n).Enabled = False Form2.Text1(n).BackColor = &H8000000F Form2.Text2(n).Enabled = False Form2.Text2(n).BackColor = &H8000000FNextEnd Sub Private Sub Option4_Click()Form2.Label6.Enabled = TrueForm2.Label7.Enabled = TrueForm2.Label8.Enabled = TrueForm2.Label9.Enabled = FalseForm2.Label10.Enabled = FalseFor n = 6 To 8 Form2.Text1(n).Enabled = True Form2.Text1(n).BackColor = &HFFFFFF Form2.Text2(n).Enabled = True Form2.Text2(n).BackColor = &HFFFFFFNextFor n = 9 To 10 Form2.Text1(n).Enabled = False Form2.Text1(n).BackColor = &H8000000F Form2.Text2(n).Enabled = False Form2.Text2(n).BackColor = &H8000000FNextEnd Sub Private Sub Option5_Click()Form2.Label6.Enabled = TrueForm2.Label7.Enabled = TrueForm2.Label8.Enabled = TrueForm2.Label9.Enabled = TrueForm2.Label10.Enabled = FalseForm2.Text1(10).Enabled = FalseForm2.Text1(10).BackColor = &H8000000FForm2.Text2(10).Enabled = FalseForm2.Text2(10).BackColor = &H8000000FFor n = 6 To 9 Form2.Text1(n).Enabled = True Form2.Text1(n).BackColor = &HFFFFFF Form2.Text2(n).Enabled = True Form2.Text2(n).BackColor = &HFFFFFFNextEnd Sub Private Sub Option6_Click()Form2.Label6.Enabled = TrueForm2.Label7.Enabled = TrueForm2.Label8.Enabled = TrueForm2.Label9.Enabled = TrueForm2.Label10.Enabled = TrueFor n = 6 To 10 Form2.Text1(n).Enabled = True Form2.Text1(n).BackColor = &HFFFFFF Form2.Text2(n).Enabled = True Form2.Text2(n).BackColor = &HFFFFFFNextEnd Sub Form2 Option Base 1Dim m As IntegerDim X(10) As SingleDim Y(10) As Single Private Sub Command1_Click() '进入第三个绘图窗体Form1.HideForm2.HideForm3.Show Dim A As Single '截距Dim B As Single '斜率Dim c As SingleDim d As SingleDim e As SingleDim f As SingleDim W As SingleDim R As SingleDim T As Single'讨论点的个数If Form2.Text1(5).Enabled = True Then m = 5If Form2.Text1(6).Enabled = True Then m = 6If Form2.Text1(7).Enabled = True Then m = 7If Form2.Text1(8).Enabled = True Then m = 8If Form2.Text1(9).Enabled = True Then m = 9If Form2.Text1(10).Enabled = True Then m = 10 '对点的x.y坐标进行赋值If m = 5 Then For n = 1 To 5 X(n) = Text1(n).Text Y(n) = Text2(n).Text NextEnd IfIf m = 6 Then For n = 1 To 6 X(n) = Text1(n).Text Y(n) = Text2(n).Text NextEnd IfIf m = 7 Then For n = 1 To 7 X(n) = Text1(n).Text Y(n) = Text2(n).Text NextEnd IfIf m = 8 Then For n = 1 To 8 X(n) = Text1(n).Text Y(n) = Text2(n).Text NextEnd IfIf m = 9 Then For n = 1 To 9 X(n) = Text1(n).Text Y(n) = Text2(n).Text NextEnd IfIf m = 10 Then For n = 1 To 10 X(n) = Text1(n).Text Y(n) = Text2(n).Text NextEnd If For n = 1 To m c = X(n) + c d = X(n) * X(n) + d e = X(n) * Y(n) + e f = Y(n) + fNextA = (e * c - f * d) / (c * c - m * d) '计算直线的截距B = (c * f - m * e) / (c * c - m * d) '计算直线的斜率 '打印数据方程的位置Form3.CurrentX = 200Form3.CurrentY = 350Form3.Print "直线斜率(B)=" & BForm3.CurrentX = 200Form3.CurrentY = 580Form3.Print "直线截距(A)=" & AForm3.CurrentX = 200Form3.CurrentY = 810Form3.Print "直线方程为:"; Spc(3); "Y=" & B & "X+" & A'在坐标图上打印出点来For n = 1 To m Form3.PSet (360 + 37 * X(n), 5400 - 37 * Y(n)), RGB(0, 0, 0)NextW = 5400 - 3700 * B - 37 * AR = 360 + (3700 - 37 * A) / BT = 360 - 37 * A / B'将超出坐标轴的线去掉If A >= 0 Then Form3.Line (360, 5400 - 37 * A)-(4060, W) If W < 1700 Then Form3.Line (R, 1700)-(4060, W), &H8000000F If W > 5400 And B < 0 Then Form3.Line (T, 5400)-(4060, W), &H8000000FElse Form3.Line (360 + (5400 - 37 * A) / B, 5400)-(4060, W) If W < 1700 Then Form3.Line (R, 1700)-(4060, W), &H8000000F If W > 5400 And B < 0 Then Form3.Line (T, 5400)-(4060, W), &H8000000FEnd IfEnd Sub'返回第一个窗体Private Sub Command2_Click()Form1.ShowForm2.HideForm3.HideFor n = 1 To m Text1(n).Text = "" Text2(n).Text = ""NextEnd Sub Form3 '结束程序Private Sub Command1_Click()EndEnd Sub '重新开始且将FORM2的数据清空Private Sub Command2_Click()Form1.ShowForm2.HideForm3.HideFor n = 1 To 10 Form2.Text1(n).Text = "" Form2.Text2(n).Text = ""NextEnd Sub

VB高手进 大学VB课程设计 十万火急

以下代码提供参考,程序界面你可以添加空间自行设计
Option Explicit
Public a, b, c, d As Integer
Public m, n As Integer
Public i As Integer
Private Sub Command1_Click()
MsgBox "相同数学为" & Str(m) & "个," & "相同位置有" & n & "处"
i = 0: m = 0: n = 0
Me.Text2 = ""
End Sub
Private Sub Form_Load()
Text2.MaxLength = 4
Text1.Locked = True
Randomize
a = Int(Rnd * 10)
b = Int(Rnd * 10)
Do While b = a
b = Int(Rnd * 10)
Loop
c = Int(Rnd * 10)
Do While c = a Or c = b
c = Int(Rnd * 10)
Loop
d = Int(Rnd * 10)
Do While d = a Or d = b Or d = c
d = Int(Rnd * 10)
Loop
Me.Text1 = a & b & c & d
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc(a) Or KeyAscii = Asc(b) Or KeyAscii = Asc(c) Or KeyAscii = Asc(d) Then
m = m + 1
End If
If i = 0 And KeyAscii = Asc(a) Then
n = n + 1
ElseIf i = 1 And KeyAscii = Asc(b) Then
n = n + 1
ElseIf i = 2 And KeyAscii = Asc(c) Then
n = n + 1
ElseIf i = 3 And KeyAscii = Asc(d) Then
n = n + 1
End If
i = i + 1
End Sub
'今天问我们的问题,我已抽空给你完成了程序的设计,其它的你自己完成吧。只要在窗体中忝加两个文本框和一个command就可以了
Option Explicit
Public a, b, c, d As Integer
Public m, n As Integer
Public i As Integer
Private Sub Command1_Click()
Dim x As String
x = Text2.Text
Call pd(x)
If Command1.Caption = "重新开始" Then
Call Form_Load
Exit Sub
End If
If m = 4 And n = 4 Then
Text1.Text = "恭喜中奖,游戏结束!"
Command1.Caption = "重新开始"
End If
MsgBox "相同数学为" & Str(m) & "个," & "相同位置有" & n & "处"
i = 0: m = 0: n = 0
Me.Text2 = ""
End Sub
Private Sub Form_Load()
Command1.Caption = "判断"
Text2.Text = ""
Text2.MaxLength = 4
Text1.Locked = True
Randomize
a = Int(Rnd * 10)
b = Int(Rnd * 10)
Do While b = a
b = Int(Rnd * 10)
Loop
c = Int(Rnd * 10)
Do While c = a Or c = b
c = Int(Rnd * 10)
Loop
d = Int(Rnd * 10)
Do While d = a Or d = b Or d = c
d = Int(Rnd * 10)
Loop
Me.Text1 = a & b & c & d
End Sub
Public Function pd(x As String) '判断相同个数与相同位置函数
Dim n1 As String, n2 As String, n3 As String, n4 As String, s As Integer
If Len(x) < 4 Then MsgBox "请输入四个数字": Exit Function
n1 = Mid(x, 1, 1): n2 = Mid(x, 2, 1): n3 = Mid(x, 3, 1): n4 = Mid(x, 4, 1)
If Val(n1) = a Or Val(n1) = b Or Val(n1) = c Or Val(n1) = d Then m = m + 1
If Val(n2) = a Or Val(n2) = b Or Val(n2) = c Or Val(n2) = d Then m = m + 1
If Val(n3) = a Or Val(n3) = b Or Val(n3) = c Or Val(n3) = d Then m = m + 1
If Val(n4) = a Or Val(n4) = b Or Val(n4) = c Or Val(n4) = d Then m = m + 1
If Val(n1) = a Then n = n + 1
If Val(n2) = b Then n = n + 1
If Val(n3) = c Then n = n + 1
If Val(n4) = d Then n = n + 1
End Function
给的分值也太低了吧,这个东西起码要搞半天,才5分,不好意思啊,爱莫能助!
其实并不复杂,网上找一找,随机数用一个RND()函数就搞定了,剩下的逻辑判断,看你自己的逻辑了。
不是吧,这就是大学的题目?太简单了吧.可是我是手机上,帮不了你了.
你也太抠门了吧,这么点分!
看着你着急……平时不用功,现在傻了吧?
如果只是编个程序还可以,
还需要那么多附加的东西,很麻烦.
将下面所有的文字,复制到 记事本 里,
把文件保存为 csz.txt,再把扩展名改为 .frm
即最终文件全名为: csz.frm
然后,在装有VB6.0的机器上双击就可以了.
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "猜数字"
ClientHeight = 3480
ClientLeft = 45
ClientTop = 330
ClientWidth = 5970
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3480
ScaleWidth = 5970
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command1
Caption = "帮 助"
Height = 375
Left = 4140
TabIndex = 12
Top = 2700
Width = 795
End
Begin VB.OptionButton opbDH
Caption = "显示代号"
Height = 255
Left = 4200
TabIndex = 6
Top = 2280
Width = 1455
End
Begin VB.OptionButton opbWZ
Caption = "显示文字"
Height = 255
Left = 4200
TabIndex = 5
Top = 1980
Value = -1 'True
Width = 1455
End
Begin VB.CommandButton cmdTC
Caption = "退 出"
Height = 375
Left = 4980
TabIndex = 8
Top = 2700
Width = 795
End
Begin VB.TextBox txtGC
BackColor = &H00C0C0C0&
Height = 2955
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 7
Top = 120
Width = 3735
End
Begin VB.CommandButton cmdCS
Caption = "猜数"
Height = 375
Left = 5040
TabIndex = 4
Top = 1440
Width = 675
End
Begin VB.CommandButton cmdNEW
Caption = "新 题 目"
Height = 375
Left = 4080
TabIndex = 1
Top = 120
Width = 1635
End
Begin VB.TextBox txtCS
Alignment = 2 'Center
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 4080
MaxLength = 4
TabIndex = 0
Top = 1380
Width = 855
End
Begin VB.CommandButton cmdCK
Caption = "查看"
Height = 375
Left = 5040
TabIndex = 3
Top = 780
Width = 675
End
Begin VB.Label lblCS
Alignment = 2 'Center
Caption = "0"
Height = 195
Left = 1200
TabIndex = 10
Top = 3180
Width = 495
End
Begin VB.Label Label2
Caption = "469876252@qq.COM"
Height = 195
Left = 4200
TabIndex = 9
Top = 3180
Width = 1515
End
Begin VB.Label lblSWS
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 4080
TabIndex = 2
Top = 720
Width = 855
End
Begin VB.Label Label1
Caption = "猜数次数:"
Height = 195
Left = 180
TabIndex = 11
Top = 3180
Width = 915
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim sws As String '储存 四位数 的字符串
Dim cs As Long '猜数的 次数
Private Sub cmdCK_Click()
lblSWS.Caption = sws
End Sub
Private Sub cmdCS_Click()
Dim ts As String, txt As String, txtW(4) As Integer
Dim n As Integer, zqs As Integer, zqsw As Integer
ts = "请输入四位不重复的数字"
txt = txtCS.Text
'判断是否是四个字符
If Len(txt) <> 4 Then MsgBox ts: Exit Sub
For n = 1 To 4
txtW(n) = Mid(txt, n, 1)
Next n
'判断是否是四个数字
If Asc(txtW(1)) < 48 Or Asc(txtW(1)) > 57 Or Asc(txtW(2)) < 48 Or Asc(txtW(2)) > 57 Or Asc(txtW(3)) < 48 Or Asc(txtW(3)) > 57 Or Asc(txtW(4)) < 48 Or Asc(txtW(4)) > 57 Then MsgBox ts: Exit Sub
'判断是否有重复数字
If txtW(1) = txtW(2) Or txtW(1) = txtW(3) Or txtW(1) = txtW(4) Or txtW(2) = txtW(3) Or txtW(2) = txtW(4) Or txtW(3) = txtW(4) Then MsgBox ts: Exit Sub
For n = 1 To 4
If InStr(sws, txtW(n)) <> 0 Then zqs = zqs + 1
If Mid(sws, n, 1) = txtW(n) Then zqsw = zqsw + 1
Next n
If cs = 0 Then txtGC.Text = ""
cs = cs + 1
lblCS.Caption = CStr(cs)
If opbWZ.Value Then
txtGC.Text = txtGC.Text + txt + vbTab + CStr(zqs) + "个数字正确,其中" + CStr(zqsw) + "个位置也正确" + vbCrLf
Else
txtGC.Text = txtGC.Text + txt + vbTab + CStr(zqs) + "A" + CStr(zqsw) + "B" + vbCrLf
End If
If zqsw = 4 Then lblSWS.Caption = sws: MsgBox "恭喜你!你部猜中!" + vbCrLf + "猜测次数:" + CStr(cs) + vbCrLf + vbCrLf + "开始新题目!": cmdNEW_Click
End Sub
Private Sub cmdNEW_Click()
'生成新的四位数,并设置各控件的显示值
Dim sz As String
Dim n As Integer, sjs As Integer
sz = "1234567890"
Randomize Timer
sws = ""
For n = 1 To 4
sjs = Int(Rnd * Len(sz)) + 1
sws = sws + Mid(sz, sjs, 1)
sz = Left(sz, sjs - 1) + Right(sz, Len(sz) - sjs)
Next n
cs = 0
lblSWS.Caption = "????"
txtGC.Text = ""
lblCS.Caption = CStr(cs)
End Sub
Private Sub cmdTC_Click()
Unload Me
End Sub
Private Sub Form_Load()
cmdNEW_Click
txtGC.Text = "查看 按钮,可以先查看数字" + vbCrLf + "用于在游戏过程中 做弊" + vbCrLf + "如果不需要这个功能,可以将按钮的" + vbCrLf + "Visible 属性设置为 False"
End Sub
Private Sub txtCS_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdCS_Click
txtCS.SelStart = 0
txtCS.SelLength = 4
End If
End Sub

阅读更多 >>>  vb程序设计的基本步骤,VB编程的必备技巧

vb的课程设计,帮忙注释一下语句吧。

Get 语句
将一个已打开的磁盘文件读入一个变量之中。
Get [#]filenumber, [recnumber], varname
Label3(i).Visible = False
i 就是 INDEX 标签 默认INDEX 是0 在添加一个就 1 他写<> 11估计有11个标签 然后做循环
前面是空间名 中间小点. 后面是属性, visible 是可见的意思 FLASE 不可见意思
比较简单,其他有什么问题,你在提出来,提问题要说清楚,到底什么地方不懂 那么多我怎么知道你说什么
这个STU应该是程序中定义的一个类,类似于C语言中的结构体,xingming和shoujihao是两个变量。get函数见楼上的解释,trim函数表示去掉text1.text的首尾空字符,mid函数表示从源字符串中的某一位开始返回指定长度的字符,在你的函数中,也就是j+1开始,返回一位。这些应该差不多了吧.....
Private Sub Command3_Click()
Form1.Show ‘ 显示窗口:Form1
Unload Me ‘卸载Form1窗口
End Sub

Private Sub Timer1_Timer() ‘时间控件
Static Index As Integer '定义一个名称为index的静态整形变量
Dim i As Integer '定义i为整型变量
If Index <> 11 Then '如果index不等于11
Label3(Index).Visible = True ‘显示:Label3(i)
Index = Index + 1 'index的值加1
Else '如果index等于11
For i = 0 To 10
Label3(i).Visible = False ‘隐藏Label3(i)
Next i
Index = 0
End If
End Sub

Private Sub Command1_Click()
Dim i As Integer
For i = 1 To rec_total ‘i由1 到rec_total执行循环
Get #1, i, stu ‘读文件(#1)第i条记录的数据存入结构变量stu中
If Trim(Text1.Text) = Trim(stu.xingming) Then ‘如果读取的xingming与Text1的文本一样,Trim是去掉字符串首尾的空格。
rec_no = i
Get #1, rec_no, stu ‘这句可以不用,因为已用Get #1, i, stu读过了,且rec_no = i,所以两次的stu结构数据相同。
Text2.Text = stu.shoujihaoma ‘Text2中显示shoujihaoma。
End If
Next i
Dim j As Integer
For j = 0 To 10
Label3(j) = Mid(Text2.Text, j + 1, 1) ‘取Text2.Text中第j + 1个字符开始的1个字符,用Label3(j)显示,一般写成:Label3(j).Caption = Mid(Text2.Text, j + 1, 1)。但下面一句Label3(j).Visible = False又让Label3(j)隐藏,因此看不到,这就不明白作者的意图了,呵呵。
Label3(j).Visible = False ‘应该是:Label3(j).Visible = True
Label3(j).ForeColor = vbRed ‘设置Label3(j)字体颜色为红色。
Next j
Timer1.Interval = 500 ‘时钟每500ms(即0.5秒)激发一次
End Sub

Public Sub display() '定义了这个子程序,却没用到。其作用是:
Get #1, rec_no, stu ' 读取数据,结构stu的xingming与shoujihaoma
With stu ' 分别放到Text1、Text2中显示
Text1 = .xingming: Text2 = .shoujihaoma

End With
End Sub
Private Sub Command2_Click()
Timer1.Enabled = True ‘时钟可用,这样就会按时循环执行:“Private Sub Timer1_Timer()”子程序
End Sub

求帮做VB课程设计(打字游戏)

要计算正确率就很难了。。。因为需要比较的是相同的位置上的内容,而你如果有个空格或漏了或多了都是错的。。。vb想智能的话就需要很多程序了,不是那么容易就能做的了。。。所以无能为力了。。。抱歉
Dim h As Integer
Dim n As Integer
Private Function zi()
Randomize
If Form1.Option1.Value Then
a = Int((122 - 97 + 1) * Rnd + 97)
ElseIf Form1.Option2.Value Then
a = Int((90 - 65 + 1) * Rnd + 65)
ElseIf Form1.Option3.Value Then
a = Int((126 - 48 + 1) * Rnd + 48)
End If
zi = Chr(a)
End Function
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim b As Integer
Dim c As Integer
b = -1
c = -1
For i = 0 To Label1.Count - 1
If Label1(i).Caption = Chr(KeyAscii) Then
If Label1(i).Top > b Then
c = i
End If
End If
Next
If c > -1 Then
Image1.Top = Label1(c).Top
Image1.Left = Label1(c).Left
Image1.Visible = True
Label1(c).Top = -10
Label1(c).Caption = zi
h = h + 1
Label2.Caption = "当前得分:" & h
If Form1.Option4.Value Then
h = h + 1
ElseIf Form1.Option5.Value Then
h = h + 2
ElseIf Form1.Option6.Value Then
h = h + 3
End If
End if
If KeyAscii = 27 Then
If MsgBox("真的要退出吗", vbYesNo) = vbYes Then
MsgBox "您的得分" & h & "分", , "成绩"
Unload Form2
Form1.Show
End If
End If
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Image1.Visible = False
End Sub
Private Sub Form_Load()
Dim lu As String
lu = App.Path
If Right(lu, 1) <> "/" Then
lu = lu & "/"
End If
lu = lu & "3.jpg"
Image1.Picture = LoadPicture(lu)
h = 0
n = 0
For i = 0 To Label1.Count - 1
Label1(i).Top = 0 - 380 * (i + 1)
Label1(i).Caption = zi
Next
End Sub
Private Sub Timer1_Timer()
For i = 0 To Label1.Count - 1
If Form1.Option4.Value Then
If h > 100 Then
Label1(i).Top = Label1(i).Top + 80
Else
Label1(i).Top = Label1(i).Top + 40
End If
ElseIf Form1.Option5.Value Then
If h > 200 Then
Label1(i).Top = Label1(i).Top + 120
Else
Label1(i).Top = Label1(i).Top + 60
End If
ElseIf Form1.Option6.Value Then
If h > 300 Then
Label1(i).Top = Label1(i).Top + 160
Else
Label1(i).Top = Label1(i).Top + 80
End If
End If
If Label1(i).Top > 6525 Then
n = n + 1
Label3.Caption = "掉落个数:" & n
Label1(i).Top = -10
Label1(i).Caption = zi
End If
If n = 27 Then
If MsgBox("掉落的个数已经超过" & n & "个,是否重新开始", vbYesNo) = vbYes Then
MsgBox "您的得分:" & h & "分", , "成绩"
Unload Form2
Form1.Visible = True
Exit Sub
Else
MsgBox "您的得分" & h & "分", , "成绩"
End
End If
End If

Next
End Sub

用vb编写课程设计 英语接龙

Private Sub Command1_Click()
If Text2.Text = "" Then Exit Sub
If Right(Text1.Text, 1) = Left(Text2.Text, 1) Then
MsgBox "正确", vbOKOnly + vbInformation, "恭喜"
Text1.Text = Text2.Text
Text2.Text = ""
Text2.SetFocus
Else
MsgBox "错误", vbOKOnly + vbCritical, "错误"
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
Text2.SetFocus
End If
End Sub
Private Sub Form_Load()
Text1.Text = "English" '这里显示上一个单词,初始第一个单词为English
Text2.Text = "" '这里输入接龙单词
End Sub
Private Sub Command1_Click()
If Text2.Text = "" Then Exit Sub
If Right(Text1.Text, 1) = Left(Text2.Text, 1) Then
MsgBox "正确", vbOKOnly + vbInformation, "恭喜"
Text1.Text = Text2.Text
Text2.Text = ""
Text2.SetFocus
Else
MsgBox "错误", vbOKOnly + vbCritical, "错误"
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
Text2.SetFocus
End If
End Sub
Private Sub Form_Load()
Text1.Text = "English" '这里显示上一个单词,初始第一个单词为English
Text2.Text = "" '这里输入接龙单词
End Sub

网站数据信息

"vb课程设计实例,VB课程设计,谁能帮帮我!!!"浏览人数已经达到21次,如你需要查询该站的相关权重信息,可以点击进入"Chinaz数据" 查询。更多网站价值评估因素如:vb课程设计实例,VB课程设计,谁能帮帮我!!!的访问速度、搜索引擎收录以及索引量、用户体验等。 要评估一个站的价值,最主要还是需要根据您自身的需求,如网站IP、PV、跳出率等!