End If
For i = 1 To 编号 - 1
If Not myfile.AtEndOfLine Then myfile.SkipLine tempp = myfile.Line End If Next
If flag = 1 Then
If Not myfile.AtEndOfLine Then 查询 = myfile.ReadLine Else
查询 = \编号不存在!\ End If
myfile.close Else
查询 = \文件不存在!\ End If
Set fso = Nothing End Function
Function 搜索(文本路径, 关键字) Dim ForReading, ForWriting
ForReading = 1 : ForWriting = 2 : 搜索 = \ Dim objFSO, objFile, strLine, strNewFile
Set objFSO = CreateObject(\ Set objFile = objFSO.OpenTextFile(文本路径, ForReading) Do Until objFile.AtEndOfStream strLine = objFile.Readline
If Instr(1, strLine, 关键字) > 0 Then 搜索 = strLine & \搜索 TracePrint \搜索=\搜索
strNewFile = strNewFile & strLine & vbcrlf Loop
objFile.Close
Set objFile = objFSO.OpenTextFile(文本路径, ForWriting) objFile.Write strNewFile objFile.Close
Set objFSO = Nothing End Function
Sub 删除(文本路径, 编号)
Dim ForReading ,ForWriting ForReading = 1 ForWriting = 2
Dim objFSO,objFile,strLine,strNewFile
Set objFSO = CreateObject(\ Set objFile = objFSO.OpenTextFile(文本路径,ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.Readline
If CInt(编号) = objFile.Line - 1 or CInt(编号) = 0 Then strNewFile = strNewFile Else
strNewFile = strNewFile & strLine & vbcrlf End If Loop
objFile.Close
Set objFile = objFSO.OpenTextFile(文本路径,ForWriting) objFile.Write strNewFile objFile.Close
Set objFSO = Nothing End Sub
Sub 增加(文本路径, 文本内容) Dim ForReading ,ForWriting ForReading = 1 : ForWriting = 2
Dim objFSO, objFile, strLine, strNewFile
Set objFSO = CreateObject(\ Set objFile = objFSO.OpenTextFile(文本路径, ForReading) Do Until objFile.AtEndOfStream strLine = objFile.Readline
strNewFile = strNewFile & strLine & vbcrlf Loop
TracePrint objFile.Line
strNewFile = strNewFile & objFile.Line & \文本内容 & vbcrlf objFile.Close
Set objFile = objFSO.OpenTextFile(文本路径, ForWriting) objFile.Write strNewFile objFile.Close
Set objFSO = Nothing End Sub EndScript
'六、3、动态监控文本内容,当文本内容增加时(文本内容不会减少)自动输出增加的内容到所有标题包含\接收\关键字的文本(批量消息发送器),请写出代码
'六、4、写一个子程序,可以改变窗口内的某个子窗口的大小为特定值,子窗口大小随顶层窗口变化而比例变化(提示:改变顶层窗口,判断子窗口大小),请写出代码 '六、5、利用函数输出杨辉三角,需要的参数为杨辉三角的行数,请写出代码 '六、杨辉三角百度说明:http://baike.http://www.wodefanwen.com//view/7804.htm
'五:1、写出三种计算颜色相似度的算法,函数返回值为相似度.请写出代码 MsgBox 颜色相似度1(\颜色相似度1\MsgBox 颜色相似度2(\颜色相似度2\MsgBox 颜色相似度3(\颜色相似度3\
Function 颜色相似度1(当前颜色, 对比颜色)
Call Plugin.Color.ColorToRGB(当前颜色, R1, G1, B1) Call Plugin.Color.ColorToRGB(对比颜色, R2, G2, B2)
颜色相似度1 = 1 - round((abs((R1 - R2) / 255) + abs((G1 - G2) / 255) + abs((B1 - B2) / 255)) / 3, 3) End Function
Function 颜色相似度2(当前颜色, 对比颜色)
Call Plugin.Color.ColorToRGB(当前颜色, R1, G1, B1) Call Plugin.Color.ColorToRGB(对比颜色, R2, G2, B2)
颜色相似度2 = 1 - round((abs(R1 - R2) + abs(G1 - G2) + abs(B1 - B2)) / 255 / 3, 3)
End Function
Function 颜色相似度3(当前颜色, 对比颜色)
Call Plugin.Color.ColorToRGB(当前颜色, R1, G1, B1) Call Plugin.Color.ColorToRGB(对比颜色, R2, G2, B2)
颜色相似度3 = 1 - round((abs(R1 / 255 - R2 / 255) + abs(G1 / 255 - G2 / 255) + abs(B1 / 255 - B2 / 255)) / 3, 3) End Function
'五:2、(前台)区域范围为(100,150)到(200,300)内的所有点是否均为\是则弹出对话框\没有其他颜色\否则弹出第一个点的颜色值并退出程序. 请写出代码
Dim x, y, RtColor x = 100 : y = 150 Do While y < 301
For x = 100 To 200
RtColor = Plugin.Color.GetPixelColor(x, y, 0) If RtColor <> \ Next : y = y + 1 Loop
If RtColor <> \
MessageBox X & \坐标点颜色为:\Else
MessageBox \没有其他颜色\End If EndScript
'五:3、写一个函数,要求:返回一个数值范围内所有偶数之和。参数1、参数2:整数型,数字 提示:For循环与VBS命令函数应用。 TracePrint 求偶数之和(1, 61) TracePrint 求偶数之和(3, 19) TracePrint 求偶数之和(0, 83) TracePrint 求偶数之和(2, 1) EndScript
Function 求偶数之和(参数1, 参数2) Dim 差, i
求偶数之和 = 0 : 差 = Abs(参数1 - 参数2) If 差 mod 2 = 1 Then : 差 = 差 - 1 : End If For i = 0 To 差 / 2 - 1 求偶数之和 = 求偶数之和 + 差 - i * 2 'TracePrint \ 求偶数之和=\求偶数之和 & \ 差=\差 - i * 2 Next End Function
'五:4、遍历字符串\取出所有小写字母及数字,并按照与原来相反的顺序拼接成新的字符串,请写出代码 Dim Str, k, XiaoXie, 新字符串 Str = \For k = 1 To Len(Str)
XiaoXie = LCase(mid(Str, k, 1)) If XiaoXie = mid(Str, k, 1) Then
新字符串 = XiaoXie & 新字符串 End If Next
TracePrint 新字符串
'五:5、写一个脚本,要求:在画图工具中画一个渐变放大的多边形(大于4边)漩涡效果图。 提示:For循环的应用。 Call 画多边漩涡(400, 200, 50, 7) //五边形 EndScript
Sub 画多边漩涡(x, y, r, n)
//x 圆心横坐标 y 圆心纵坐标 //r 半径 n 多边形的边数 Const PI = 3.1415926 Dim x1, y1 //起点坐标 dim x2, y2 //下一个点坐标 x1 = x y1 = y - r Dim t t = PI For i = 1 To 30 If i > 1 Then
MoveTo x1, y1 Delay 20 LeftUp 1
End If MoveTo x1, y1 Delay 20 LeftDown 1 t = t - pi * 2 / n
x2 = x + int(r * sin(t))
y2 = y + int(r * cos(t)) //更新起点坐标 x1 = x2 y1 = y2 r = r + 2 Next End Sub
'五:1、写一个脚本,要求:在画图工具中画一个渐变放大的圆形漩涡效果图。提示:cos函数与sin函数应用。 Call 画漩涡(420, 280) EndScript
Function 画漩涡(起点X, 起点Y) Dim HX, HY, n n = 1
While HX < 600
MoveTo HX, HY : Delay 3
HX = 起点X + cos(n) + n * sin(n) HY = 起点Y + sin(n) - n * cos(n) n = n + 0.1 Wend End Function
'五:2、随机生成一个1~100之间的整数,玩家可以通过函数InputBox命令输入数字来猜测那未知的随机数字,猜对则退出游戏,猜错则提示答案的范围(猜数游戏),请写出代码:
Dim 随机, 猜测, 下限, 上限, 次数 Randomize
随机 = Int(100 * Rnd + 1) TracePrint \随机=\随机 下限 = 1 : 上限 = 100
猜测 = Cint(InputBox(\请输入你的猜测\猜数字游戏\For 次数 = 1 To 99 : Delay 100
If 猜测 < 随机 and 猜测 > 下限 Then : 下限 = 猜测 ElseIf 猜测 > 随机 and 猜测 < 上限 Then : 上限 = 猜测 ElseIf 猜测 = 随机 Then
MsgBox \总共\次数 & \次猜中了 八戒 看来今年你又要涨价了!\64, \程序·提示\ Exit For End If
猜测 = Cint(InputBox(\答案范围为:\下限 & \上限, \程序·提示 还可再猜\次数 & \次 \Next
EndScript
'五:3、筛选出100以内所有个位数加十位数等于10的数,例如82,8+2=10满足