童话故事脚本文本文档

发布时间:2021-06-10 来源:脚本之家 点击:



1.建立含有如下控件的窗体:

控件NAMECAPTION
窗体FORM1用VB6.0设计ABOUT窗口命令按钮COMMAND1关于销售管理系统

2.程序清单:

PrivateDeclareFunctionGetWindowWordLib"user32"
(ByValhwndAsLong,ByValnIndexAsLong)AsInteger

PrivateDeclareFunctionShellAboutLib
"shell32.dll"Alias"ShellAboutA"(ByValhwndAsLong,
ByValszAppAsString,ByValszOtherStuffAsString,
ByValhIconAsLong)AsLong

PrivateDeclareFunctionExtractIconLib
"shell32.dll"Alias"ExtractIconA"(ByValhinstAsLong,
ByVallpszExeFileNameAsString,ByValnIconIndexAs
Long)AsLongPrivateDeclareFunctionGetDiskFreeSpace
Lib"kernel32"Alias"GetDiskFreeSpaceA"(ByVal
lpRootPathNameAsString,lpSectorsPerClusterAsLong,
lpBytesPerSectorAsLong,lpNumberOfFreeClustersAs
Long,lpTotalNumberOfClustersAsLong)AsLongPrivate
DeclareFunctionGetDriveTypeLib"kernel32"Alias
"GetDriveTypeA"(ByValnDriveAsString)AsLong

PrivateDeclareSubGetSystemInfoLib"kernel32"
(lpSystemInfoAsSYSTEM_INFO)PrivateDeclareFunction
GetSystemMetricsLib"user32"(ByValnIndexAsLong)As
Long

PrivateConstGWL_EXSTYLE=(-20)
PrivateConstGWL_STYLE=(-16)
PrivateConstGWL_WNDPROC=(-4)
PrivateConstGWL_HINSTANCE=(-6)
PrivateTypeSYSTEM_INFO
dwOemIDAsLong
dwPageSizeAsLong
lpMinimumApplicationAddressAsLong
lpMaximumApplicationAddressAsLong
dwActiveProcessorMaskAsLong
dwNumberOrfProcessorsAsLong
dwProcessorTypeAsLong
dwAllocationGranularityAsLong
dwReservedAsLong
EndType
PrivateConstSM_CXSCREEN=0
PrivateConstSM_CYSCREEN=1

PrivateSubCommand1_Click()
DimhinstAsLong
DimiconsAsLong
DimaboutsAsLong
DimdispxAsString
DimdispyAsString
DimcpsAsString
Dimspace1AsString
Dimspace2AsString
hinst=GetWindowWord(Me.hwnd,GWL_HINSTANCE)
icons=ExtractIcon(hinst,"d:fpw26foxprow.exe",0)
DimsysinfoAsSYSTEM_INFO
Dimcls1AsLong
Dimcls2AsLong
DimsecsAsLong
DimbytesAsLong
DimbuffsAsString
buff="C:"
x=GetDriveType(buffs)
x=GetDiskFreeSpace(buffs,secs,bytes,cls1,cls2)
cls1=cls1*secs*bytes
cls2=cls2*secs*bytes
space1="C驱动器总共容量:" Format$(cls2/1024,"#,#") "千字节"
space2="C驱动器可用容量:
" Format$(cls1/1024,"#,#") "千字节"
x=GetSystemMetrics(SM_CXSCREEN)
dispx="显示器分辨率:" Str$(x)
x=GetSystemMetrics(SM_CYSCREEN)
dispy=Str$(x)
CallGetSystemInfo(sysinfo)
SelectCasesysinfo.dwProcessorType
Case386
cpus="处理器类型:386"
Case486
cpus="处理器类型:486"
Case586
cpus="处理器类型:586"
EndSelect
abouts=ShellAbout(Me.hwnd,"演示程序",
"销售管理系统V2.0版权所有[C]1998-1999蔡可训"
&Chr$(13)&Chr$(10)&space1&Chr$(13)&Chr$(10)
&space2&Chr$(13)&Chr$(10)&cpus "" dispx
"*" dispy,icons)
EndSub

----以上程序在WINDOWS98,VISUALBASIC6.0FORWINDOWS环境下运行通过.用户可以将其加入应用系统的ABOUT菜单项,通过菜单项调用它,效果更好->

  至此,想必大家对VBS编程也有了初步的了解了,要更深入地学习还要学习选择结构和循环结构,这在后面的文章中将涉及到

和平精英脚本下载手机免费版
"
WScript.Quit
End If
End If
outDateFile="Excel2Access.mdb" '要转换的数据库名字
Tables="学生信息表" '要创建以及写入的表名
Row="系别,班别,姓名,学号,性别,政治面貌,出生年月,身份证号码,家庭地址,生源地毕业学校" '要创建以及写入的列名,用逗号隔开
Set Fso=CreateObject("Scripting.FileSystemObject")
If Fso.FileExists(outDateFile) Then
Call Writemdb
Else
Set DB=CreateObject("ADOX.Catalog")
DB.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&outDateFile)
Set ADOXTable=CreateObject("ADOX.Table")
ADOXTable.Name=Tables
For Each s In Split(Row, ",", -1, 1)
ADOXTable.Columns.Append s,202 ' 字符串
Next
DB.Tables.Append ADOXTable
Set DB=Nothing
Call Writemdb
End If
Set Fso=Nothing
Sub Writemdb()
Set objExcel=CreateObject("Excel.Application")
Set objWorkbook=objExcel.Workbooks.Open(InXlsFile)
Set Conn=CreateObject("ADODB.Connection")
ConnStr="DBQ="&outDateFile&";Driver={Microsoft Access Driver (*.mdb)};"
Conn.Open ConnStr
Rows=objExcel.ActiveSheet.UsedRange.Rows.Count
Columns=objExcel.ActiveSheet.UsedRange.Columns.Count
For i=1 To rows
tmp=""
For j=1 To Columns
If Len(objExcel.Cells(i,j).Value) <> 0 Then
If j<>Columns Then
tmp=tmp&"'"&objExcel.Cells(i,j).Value&"',"
Else
tmp=tmp&"'"&objExcel.Cells(i,j).Value&"'"
'wscript.Echo "Insert Into "&Tables&"("&row&") Values("&tmp&")"
Conn.Execute "Insert Into "&Tables&"("&Row&") Values("&tmp&")"
End If
Else
Exit For
End If
Next
Next
objWorkbook.Close
objExcel.Quit
Conn.Close
Set Conn=Nothing
Set objWorkbook=Nothing
Set objExcel=Nothing
wscript.Echo "处理完毕,请检查是否正常导入"
End Sub

请给标准工程添加ListBox和TextBox控件各一个,其各项属性均取默认值,然后将下列代码拷贝到你的工程:

OptionExplicit

'申明API函数
PrivateDeclareFunctionSendMessageLib"user32"Alias"SendMessageA"(ByValhwndAsLong,ByValwMsgAsLong,ByValwParamAsInteger,ByVallParamAsAny)AsLong

ConstLB_FINDSTRING=&H18F'常数

PrivateSubForm_Load()

'给列表框添加26个字母(大写)
DimiAsInteger
Fori=Asc("A")ToAsc("Z")
List1.AddItemChr$(i)
Next
Text1=""'令文本框为空

EndSub

PrivateSubText1_KeyPress(KeyAsciiAsInteger)

Text1=""'按下任意键则令原内容消失
Text1.SelLength=1'限制长度
Text1.SelText=Chr(KeyAscii)'显示键盘符号
KeyAscii=0'禁止响铃
'ListBox中的项目文本若与文本框的一致则选中(高亮)
List1.ListIndex=SendMessage(List1.hwnd,LB_FINDSTRING,-1,ByValCStr(Text1.Text))

EndSub

以上程序适用于单项目为多个字母的查询,但必须注意,在TextBox的KeyPress事件中要作相应的改动

1.上传的时候可以将图片高宽存到数据库里,用的时候调出来判断,但那种方法相比较下边的麻烦.
2.用VBSCRIPT里的一个函数loadpicture
picurl'图片地址
'取出高宽

使用图片前选调出来并取得图片大小
setmyImg=loadpicture(server.mappath(picurl))
iWidth=round(myImg.width/26.4583)
iHeight=round(myImg.height/26.4583)

调用时用iwidth和iheight判断就可以了,

->

dimIISCount,IISObject,logfiledir,fso,LogFilePeriods,inputtime,site,sites,i,j,sitename(999),WshShell
'onerrorresumenext
setWshShell=WScript.CreateObject("WScript.Shell")
Setfso=CreateObject("scripting.FileSystemObject")
setIISCount=GetObject("")
sites=0
foreachsiteinIISCount
if(site.class="IIsWebServer")then
sitename(sites)=site.name
sites=sites+1
endif
next

MsgBox"IIS中一共"&sites&"个站点,ID分别为:"
forj=1tosites-1
MsgBoxsitename(j)
next

inputtime=inputbox("您要备份哪天的日志?如备份2004-01-01,则输入040101")
MsgBox"备份"&inputtime&"天的日志"

MsgBox"开始备份.............."
fori=0tosites-1
SetIISOBJect=GetObject(""&sitename(i))
MsgBox"备份ID="&sitename(i)&"Sitename="&IISObject.servercomment&"的站点"
logfiledir=IISObject.LogFileDirectory&"w3svc"&sitename(i)'设置第一个站点的日志路径
if(Err.Number<>0)thenlogfiledir=IISCount.LogFileDirectory
Err.clear
'ifIISObject.LogFilePeriod=1thenLogFilePeriods="days"
'ifIISObject.LogFilePeriod=2thenLogFilePeriods="weeks"
'ifIISObject.LogFilePeriod=3thenLogFilePeriods="months"
'ifIISObject.LogFilePeriod=4thenLogFilePeriods="hours"
'ifIISObject.LogFilePeriod=0ANDIISObject.LogFileTruncateSize=-1thenLogFilePerirods="onefile"
'ifIISObject.LogFilePeriod=0ANDIISObject.LogFileTruncateSize>0thenLogFilePerirods="size"&IISObject.LogFileTruncateSize
LogFilePeriods=IISObject.LogFilePeriod
if(Err.Number<>0)thenLogFilePeriods=IISCount.LogFilePeriod
Err.clear
if(NOTLogFilePeriods=1ANDNOTLogFilePeriods=4)then
MsgBox"对不起,您的日志偶就不给备份,咋地吧"
WScript.quit
endif
if(NOTfso.folderexists("d:backup"))then
MsgBox"thefolderd:backupisnotexist,nowcreateit"
fso.CreateFolder("d:backup")
Msgbox"createdd:backupsuccuful"
endif
if(NOTfso.FolderExists("d:backup"&IISObject.servercomment))then
MsgBox"thefolderd:backup"&IISObject.servercomment&"isnotexist,nowcreateit"
fso.CreateFolder("d:backup"&IISObject.servercomment)
MsgBox"createdd:backup"&IISObject.servercomment&"succuful"
endif

MsgBox"nowbackupthelogfiles"
logfiledir=WshShell.ExpandEnvironmentStrings(logfiledir)'将环境变量转换成字符串
MsgBoxlogfiledir
fso.Copyfilelogfiledir&"ex"&inputtime&"*","d:backup"&IISObject.servercomment
ifErr.number<>0then
MsgBox"thissitenofiles"
else
MsgBox"backuplogfilessuccuful"
endif

inputifdel=inputbox("是否删除已备份文件?输入“YES”进行删除")
ifinputifdel="YES"then
fso.DeleteFile(logfiledir&"ex"&inputtime&"*")
MsgBox"删除文件成功"
else
MsgBox"文件已保留"
endif
next
MsgBox"备份所有的日志文件成功,嘿嘿"



1.如果你是新建一个程序
当你新建一个程序时,在FROM中要先添加DATA控件,再添加ADO控件,OK一切正常
2.如果你已有一个程序,还想添加一个FROM(其中包括DATA控件)
解决方法是:1.新建FORM,建一个DATA控件,输入你要输入的代码,保存文件
2.添加文件,把你原来的工程文件添加进来
3.改变工程属性,把启动对象设置为你原来的工程

注意事项:ADO控件在DATA控件前面加入=“错误”
ADO控件在DATA控件后面加入=“正确”->

评级战场

->

'
exit sub
end if
set lct=createobject("wbemscripting.swbemlocator") '创建服务器定位对象'
on error resume next '使脚本宿主忽略非致命错误'
set wmi=lct.connectserver(.ip.value,"root/cimv2",.user.value,.pass.value) '连接到root/cimv2名字空间'
if err.number then '自己捕捉错误并处理'
wnd.alert("连接WMI服务器失败") '这里只是简单的显示“失败”'
err.clear
on error goto 0 '仍然让脚本宿主处理全部错误'
exit sub
end if
if .app.checked then clearlog "application" '清除每种选中的日志'
if .sys.checked then clearlog "system"
if .sec.checked then clearlog "security" '注意,在XP下有限制,不能清除安全日志'
wnd.alert("日志已清除")
end with
end sub

sub clearlog(name)
wql="select * from Win32_NTEventLogFile where logfilename='"&name&"'"
set logs=wmi.execquery(wql) '注意,logs的成员不是每条日志,'
for each l in logs '而是指定日志的文件对象。

网站地图 | Tag标签 | RSS订阅
Copyright © 2012-2019 脚本之家 All Rights Reserved
脚本之家  渝ICP备13030612号