1这是一个复制机票编码的能够自动生成发短信的小程序,类型是VBScript Script文件,如下图
以前在winXP系统一直可以使用,现在换了一台新电脑使用的是win10就会出现错误,如下图
2我们操作流程如下:
(1)在中航信系统为客人订位,如下图
(2)复制这个编码里面的内容
(3)双击“机票短信”这个VBScript Script文件,生成一个运行结果,如下图
(4)点击确定就可以复制生成短信发给客人,就这里出现了错误,如下图
5要求是,例如上面这个编码要求能复制 成这样即可:王大可(510104201603220064),您于2021-1-16乘坐北京首都T3航站楼飞成都T2航站楼CA4116航班,15:30起飞,19:05到,请仔细核对航班信息,祝旅途愉快! 以此内推
qq 386847535 你把文件发给我看看
我完全不懂代码,怎么贴
Dim objHtmlDoc
Set objHtmlDoc = CreateObject("htmlfile")
strCBD=objHtmlDoc.parentWindow.clipboardData.GetData("text")
'读取文件
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFileIN = fso.OpenTextFile("原始数据.txt", ForWriting)
if strCBD="" then
msgbox("请先复制所需要的信息")
else
MyFileIN.write strCBD
end if
MyFileIN.close
Set objHtmlDoc = Nothing
Set MyFile = fso.OpenTextFile("原始数据.txt", ForReading)
ReadAllTextFile = MyFile.ReadAll '读取所有的行
Dim strOut '输出的结果
strOut=""
Dim strarrHuanhangfu
dim j '人数
dim n
n=0
dim cost1
dim cost2
dim dicHBInfo '创建一个变量。放入航班基本信息
Set dicHBInfo = CreateObject("Scripting.Dictionary")
Dim dic '创建一个变量。放入登机牌号
Set dic = CreateObject("Scripting.Dictionary")
dim dicname '创建一个变量。放入人员姓名
Set dicname = CreateObject("Scripting.Dictionary")
strarrHuanhangfu = Split(ReadAllTextFile,Chr(13) & Chr(10)) '按换行符分割成数组
getProperNum(strarrHuanhangfu) '获取到人数及其登机牌号
strclearKG=clearKG(strarrHuanhangfu) '将多空格 换成 单空格
strclearKGarr = Split(strclearKG," ")
'*********************************填满dicname************************
for p=1 to j
dicname.add p , split(strclearKGarr(p-1),".")(1)
if instr(dicname.item(p),"CHD")>0 then
namegai=Replace(dicname.item(p),"CHD","") '处理CHD的情况
strOut=strOut+namegai+"("+dic.item(cstr(p))+") " 'strOut中放入了人名和对应的编号
else
strOut=strOut+dicname.item(p)+"("+dic.item(cstr(p))+") " 'strOut中放入了人名和对应的编号
end if
next
strOut=trim(strOut)+"旅客,您于"
mouth = changeMouth("MAR") '获取月份
hangbanindexS = gethangbaninfo(strarrHuanhangfu) '获取航班信息起始行的编号
hangbancount = ubound(split(ReadAllTextFile," E")) '航班数
for y=hangbanindexS to (hangbancount+hangbanindexS-1)
strHuanhangfuR = trim(split(strarrHuanhangfu(y),". ")(1))
if instr(strarrHuanhangfu(y),"E T") > 0 then
dicHBInfo.add "strHBId"+cstr(y) , splithangbaninfo(strHuanhangfuR,0,6) '航班id
if left(splithangbaninfo(strHuanhangfuR,13,2),1)="0" then
dayinfo=right(splithangbaninfo(strHuanhangfuR,13,2),1)
else
dayinfo=splithangbaninfo(strHuanhangfuR,13,2)
end if
dicHBInfo.add "strHBDay"+cstr(y) , dayinfo '航班日期
dicHBInfo.add "strHBMou"+cstr(y) , splithangbaninfo(strHuanhangfuR,15,3) '航班月份
dicHBInfo.add "strHBJCF"+cstr(y) , splithangbaninfo(strHuanhangfuR,20,3) '航班机场 from
dicHBInfo.add "strHBJCT"+cstr(y) , splithangbaninfo(strHuanhangfuR,23,3) '航班机场 to
dicHBInfo.add "strHBTimeF"+cstr(y) , splithangbaninfo(strHuanhangfuR,33,4) '出发时间 from
dicHBInfo.add "strHBTimeT"+cstr(y) , splithangbaninfo(strHuanhangfuR,38,4) '出发时间 To
dicHBInfo.add "strHBHZF"+cstr(y) , splithangbaninfo(strHuanhangfuR,54,2) '航站楼 from
dicHBInfo.add "strHBHZT"+cstr(y) , splithangbaninfo(strHuanhangfuR,56,2) '航站楼 To
mouth = changeMouth(dicHBInfo.item("strHBMou"+cstr(y)))
if instr(dicHBInfo.item("strHBHZT"+cstr(y)) ,"T") > 0 then
strOut=strOut+getYear+"-"+cstr(mouth)+"-"+dicHBInfo.item("strHBDay"+cstr(y))+"乘坐"+readJCDM(dicHBInfo.item("strHBJCF"+cstr(y)))+dicHBInfo.item("strHBHZF"+cstr(y))+"航站楼"+"飞"+readJCDM(dicHBInfo.item("strHBJCT"+cstr(y)))+dicHBInfo.item("strHBHZT"+cstr(y))+"航站楼"+dicHBInfo.item("strHBId"+cstr(y))+"航班,"+numToTime(dicHBInfo.item("strHBTimeF"+cstr(y)))+"起飞,"+numToTime(dicHBInfo.item("strHBTimeT"+cstr(y)))+"到达;"
else
strOut=strOut+getYear+"-"+cstr(mouth)+"-"+dicHBInfo.item("strHBDay"+cstr(y))+"乘坐"+readJCDM(dicHBInfo.item("strHBJCF"+cstr(y)))+dicHBInfo.item("strHBHZF"+cstr(y))+"航站楼"+"飞"+readJCDM(dicHBInfo.item("strHBJCT"+cstr(y)))+dicHBInfo.item("strHBId"+cstr(y))+"航班,"+numToTime(dicHBInfo.item("strHBTimeF"+cstr(y)))+"起飞,"+numToTime(dicHBInfo.item("strHBTimeT"+cstr(y)))+"到达;"
end if
elseif instr(strarrHuanhangfu(y),"E --") > 0 then
dicHBInfo.add "strHBId"+cstr(y) , splithangbaninfo(strHuanhangfuR,0,6) '航班id
if left(splithangbaninfo(strHuanhangfuR,13,2),1)="0" then
dayinfo=right(splithangbaninfo(strHuanhangfuR,13,2),1)
else
dayinfo=splithangbaninfo(strHuanhangfuR,13,2)
end if
dicHBInfo.add "strHBDay"+cstr(y) , dayinfo '航班日期
dicHBInfo.add "strHBMou"+cstr(y) , splithangbaninfo(strHuanhangfuR,15,3) '航班月份
dicHBInfo.add "strHBJCF"+cstr(y) , splithangbaninfo(strHuanhangfuR,20,3) '航班机场 from
dicHBInfo.add "strHBJCT"+cstr(y) , splithangbaninfo(strHuanhangfuR,23,3) '航班机场 to
dicHBInfo.add "strHBTimeF"+cstr(y) , splithangbaninfo(strHuanhangfuR,33,4) '出发时间 from
dicHBInfo.add "strHBTimeT"+cstr(y) , splithangbaninfo(strHuanhangfuR,38,4) '出发时间 To
dicHBInfo.add "strHBHZF"+cstr(y) , splithangbaninfo(strHuanhangfuR,54,2) '航站楼 from
dicHBInfo.add "strHBHZT"+cstr(y) , splithangbaninfo(strHuanhangfuR,56,2) '航站楼 To
mouth = changeMouth(dicHBInfo.item("strHBMou"+cstr(y)))
strOut=strOut+getYear+"-"+cstr(mouth)+"-"+dicHBInfo.item("strHBDay"+cstr(y))+"乘坐"+readJCDM(dicHBInfo.item("strHBJCF"+cstr(y)))+"飞"+readJCDM(dicHBInfo.item("strHBJCT"+cstr(y)))+dicHBInfo.item("strHBHZT"+cstr(y))+"航站楼"+dicHBInfo.item("strHBId"+cstr(y))+"航班,"+numToTime(dicHBInfo.item("strHBTimeF"+cstr(y)))+"起飞,"+numToTime(dicHBInfo.item("strHBTimeT"+cstr(y)))+"到达;"
elseif instr(strarrHuanhangfu(y),"E T")=0 and instr(strarrHuanhangfu(y),"E --")=0 then
dicHBInfo.add "strHBId"+cstr(y) , splithangbaninfo(strHuanhangfuR,0,6) '航班id
if left(splithangbaninfo(strHuanhangfuR,13,2),1)="0" then
dayinfo=right(splithangbaninfo(strHuanhangfuR,13,2),1)
else
dayinfo=splithangbaninfo(strHuanhangfuR,13,2)
end if
dicHBInfo.add "strHBDay"+cstr(y) , dayinfo '航班日期
dicHBInfo.add "strHBMou"+cstr(y) , splithangbaninfo(strHuanhangfuR,15,3) '航班月份
dicHBInfo.add "strHBJCF"+cstr(y) , splithangbaninfo(strHuanhangfuR,20,3) '航班机场 from
dicHBInfo.add "strHBJCT"+cstr(y) , splithangbaninfo(strHuanhangfuR,23,3) '航班机场 to
dicHBInfo.add "strHBTimeF"+cstr(y) , splithangbaninfo(strHuanhangfuR,33,4) '出发时间 from
dicHBInfo.add "strHBTimeT"+cstr(y) , splithangbaninfo(strHuanhangfuR,38,4) '出发时间 To
mouth = changeMouth(dicHBInfo.item("strHBMou"+cstr(y)))
strOut=strOut+getYear+"-"+cstr(mouth)+"-"+dicHBInfo.item("strHBDay"+cstr(y))+"乘坐"+readJCDM(dicHBInfo.item("strHBJCF"+cstr(y)))+"飞"+readJCDM(dicHBInfo.item("strHBJCT"+cstr(y)))+dicHBInfo.item("strHBId"+cstr(y))+"航班,"+numToTime(dicHBInfo.item("strHBTimeF"+cstr(y)))+"起飞,"+numToTime(dicHBInfo.item("strHBTimeT"+cstr(y)))+"到达;"
end if
next
strOut=strOut+"请仔细核对航班信息,祝旅途愉快!票价:"
strarrXiexian = split(ReadAllTextFile,"/")
'获取票价
for l=0 to UBound(strarrXiexian)
if instr(strarrXiexian(l),"FCNY") > 0 then
cost1=cint(Replace(strarrXiexian(l),"FCNY",""))
elseif instr(strarrXiexian(l),"XCNY") > 0 then
cost2=cint(Replace(strarrXiexian(l),"XCNY",""))
end if
next
if j>1 then
strOut=strOut+cstr(cost1)+"+"+cstr(cost2)+"="+cstr(cost1+cost2)+"*"+cstr(j)+"="+cstr((cost1+cost2)*j)
else
strOut=strOut+cstr(cost1)+"+"+cstr(cost2)+"="+cstr(cost1+cost2)
end if
'msgbox(dicHBInfo.item("strHBJCT1"))
msgbox strOut,,"运行结果预览------确定后结果放入粘贴板中"
'msgbox("sss"+year1)
'******************************************复制到黏贴板*******************************
Sub CopyString(s)
Set forms=WScript.CreateObject("forms.form.1")
Set textbox=forms.Controls.Add("forms.textbox.1").Object
With textbox
.multiline=True
.text=s
.selstart=0
.sellength=Len(.text)
.copy
End With
End Sub
CopyString(strOut)
'*********************************************方法集锦***************************************
'********************数字转换成时间*****************************
function numToTime(str)
Tstr=trim(str)
ST=left(Tstr,2)
ET=right(Tstr,2)
numToTime=ST+":"+ET
end function
'*********************获取相应位置的字符串************************
function splithangbaninfo(str,stratLen,length)
Tstr=trim(str)
strHBInfo1=Replace(Tstr,left(Tstr,stratLen),"")
strHBInfo2=left(strHBInfo1,length)
splithangbaninfo = strHBInfo2
end function
Function gethangbaninfo(strarr)
strHB=cstr(j+1)+". "
For i=0 To UBound(strarr)
if instr(strarr(i), strHB) > 0 then
gethangbaninfo = i
end if
next
end Function
'*********************获取人数及其牌号******************************
function getProperNum(strarr)
Dim searchStr
searchStr="NI"
For i=0 To UBound(strarr)
if instr(strarr(i),searchStr) > 0 then
j=j+1
res=getStrBetween(strarr(i),"NI","/P")
k=right(trim(strarr(i)),1)
dic.add k , res
End If
Next
End function
'**********************获取两个字符串之间的字符串**********************
Function getStrBetween(Str,StartStr,EndStr)
StartStrPos = Instr(Str, StartStr)+Len(StartStr)
EndStrPos = Instr(Str,EndStr)
Length = EndStrPos - StartStrPos
Res= Mid(Str,StartStrPos,Length)
getStrBetween = Res
End Function
'*************************将多空格 换成 单空格*******************
Function clearKG(strarr)
For i=0 To UBound(strarr)
If Trim(strarr(i))<>"" Then
'msgbox(strarr(i))
str2=str2+Trim(strarr(i))+" "
clearKG = str2
End If
Next
end Function
'****************************日期转换*************************
Function changeMouth(str)
dim dicmouth '创建一个变量。放入月份
Set dicmouth = CreateObject("Scripting.Dictionary")
dicmouth.add "JAN",1
dicmouth.add "FEB",2
dicmouth.add "MAR",3
dicmouth.add "APR",4
dicmouth.add "MAY",5
dicmouth.add "HUN",6
dicmouth.add "JUL",7
dicmouth.add "AUG",8
dicmouth.add "SEP",9
dicmouth.add "OCT",10
dicmouth.add "NOV",11
dicmouth.add "DEC",12
changeMouth = dicmouth.item(str)
end Function
'******************************获取机场名称**************************
Function readJCDM(str)
dim dicJCDM
Set dicJCDM = CreateObject("Scripting.Dictionary")
Dim FileJCDM
Set FileJCDM = fso.OpenTextFile("三字代码.txt", ForReading)
ReadAllJCDM = FileJCDM.ReadAll '读取所有的行
strarrJCDM = Split(ReadAllJCDM , Chr(13) & Chr(10)) '按换行符分割成数组
for m=0 to UBound(strarrJCDM)-1
dicJCDM.add Split(strarrJCDM(m)," ")(0) , Split(strarrJCDM(m)," ")(1)
Next
readJCDM=dicJCDM.item(Trim(str))
FileJCDM.close
end function
'*******************************获取年份*********************
function getYear
mydate=date
getYear=cstr(year(mydate))
end function
那就换xp啊。。
我的电脑装不了XP
感谢 bosaidongmomo解决问题