符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
instr函数在Oracle/PLSQL中是返回要截取的字符串在源字符串中的位置。instr是一个非常好用的字符串处理函数,几乎所有的字符串分隔都用到此函数。
鸠江网站建设公司成都创新互联公司,鸠江网站设计制作,有大型网站制作公司丰富经验。已为鸠江上千余家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的鸠江做网站的公司定做!
语法如下:
instr(
string1,
string2,
start_position,nth_appearance
)
示例:
SELECT
instr('syranmo','s')
FROM
dual;
--
返回
1
SELECT
instr('syranmo','ra')
FROM
dual;
--
返回
3
SELECT
instr('syran
mo','a',1,2)
FROM
dual;
--
返回
不知道你的winsock 是udp还是tcpip协议
这里给你一个我写的实例 我是用的udp 这个发送了一段数据不一定接收就正确 所以我做了校验
'以下是发送文件的
Option Explicit
Dim GetFileNum As Integer, LenFile As Long, SendByte() As Byte '发送的包
Private Sub Command1_Click()
On Error Resume Next
Command1.Enabled = False
GetFileNum = FreeFile '取得未使用的文件号
LenFile = FileLen(Text1.Text) '获得需传送的文件的长度
If Text2.Text = "" Or Right(Left(Text2.Text, 2), 1) ":" Then Text2.Text = Text1.Text
Winsock0.SendData "#SEND STA#" LenFile "//" Text2.Text
Wt 0.5
Open Text1.Text For Binary As #GetFileNum '打开需传送的文件
Call TCPSendFile(Winsock0, GetFileNum, SplitFile) '传送文件
Me.Caption = Now
Ti.Enabled = True
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim A As String
On Error Resume Next
Command2.Top = -2000
Winsock0.RemoteHost = IPX '服务器ip
Winsock0.RemotePort = FilePort
End Sub
Private Function SplitFile() As Long '拆包'为了清晰,下面分别用两个子过程来完成计算这次还可以传多少个字节的数据和传送数据
On Error Resume Next
Dim GetCount As Long
If LenFile = 4000 Then '计算出这次可发送的字节数
GetCount = 4000
LenFile = LenFile - GetCount
Else
GetCount = LenFile
LenFile = LenFile - GetCount
End If
SplitFile = GetCount
End Function
Private Sub TCPSendFile(objWinSock As Winsock, FileNumber As Integer, SendLen As Long)
On Error Resume Next
Dim FileByte() As Byte, I As Long, j As Long, Temp As String * 4
ReDim SendByte(0)
ReDim FileByte(SendLen - 1)
Temp = SendLen + 7
SendByte = Temp '把长度负值给包头
Get #FileNumber, , FileByte '读取文件
ReDim Preserve SendByte(SendLen + 7) '把包头+到文件头
For I = 0 To UBound(FileByte)
SendByte(I + 7) = FileByte(I)
'DoEvents
Next
Winsock0.SendData SendByte
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Winsock0.Close
Err.Clear
End Sub
Private Sub TEnd_Timer()
On Error Resume Next
Winsock0.SendData "#END#"
Err.Clear
End Sub
Private Sub Ti_Timer()
On Error Resume Next
Winsock0.SendData "#ERR#"
End Sub
Private Sub Winsock0_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim S As String
Winsock0.GetData S
Select Case S
Case "ok" '成功继续发送
If LenFile = 0 Then '发送完成
If S "#SEND END#" Then Winsock0.SendData "#SEND END#"
Me.Caption = "文件上传成功!"
Command1.Enabled = True
Ti.Enabled = False
TEnd.Enabled = True
Exit Sub
Else
Me.Caption = "文件上传完成:[" Left((FileLen(Text1.Text) - LenFile) / FileLen(Text1.Text) * 100, 4) "%]"
End If
Call TCPSendFile(Winsock0, GetFileNum, SplitFile)
Case "#END#"
TEnd.Enabled = False
FMain.TiF.Enabled = True
Case "no" '不成功重发上一个包
Winsock0.SendData SendByte
End Select
End Sub
'以下是接收文件的
Option Explicit
Dim FOK As Boolean, Fs As Long, FileNumber As Integer, LenFile As Long '文件的长度
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
On Error Resume Next
Dim A As String
Me.Caption = "开始下载"
If Dir(Text2.Text) "" And ChV.Value = 0 Then
If MsgBox("文件已经存在,覆盖吗?", vbCritical + vbYesNo) = vbYes Then Kill Text2.Text Else Exit Sub
Else
Kill Text2.Text
End If
If Text2.Text = "" Then Text2.Text = Text1.Text
'Command2.Enabled = False
If Ch.Value = 0 Then A = "#DOW#" Else A = "#DOV#"
FMain.Wsk.SendData A Text1.Text
Wt 1
FMain.Wsk.SendData "#DOE#" Text2.Text
End Sub
Private Sub Form_Load()
Dim A As String
'FMain.Ts.Enabled = True
On Error Resume Next
If FMain.Cb.Text = "本地组" Or FMain.Cb.Text = "全部组" Then
Me.Caption = "请重选下载用户[“组”不能正确下载]"
Else
Command1.Top = -2000
Winsock0.LocalPort = FilePort
Winsock0.Bind
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Winsock0.Close
Err.Clear
End Sub
Private Sub La_Click()
CDL.FileName = ""
CDL.ShowOpen
Text2.Text = CDL.FileName
End Sub
Private Sub Winsock0_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim FileByte() As Byte, A As String, MendByte() As Byte, I As Long, J As Long, Temp As String, W As String
Winsock0.GetData FileByte, vbArray + vbByte '接收类型为:字节数组
J = UBound(FileByte) '获得包长
For I = 0 To 7 Step 2 '合并包头
Temp = Temp Chr(FileByte(I))
Next
For I = 0 To 9 '文件发送结束标记
A = A Chr(FileByte(I))
Next
If A = "#ERR#" Then Winsock0.SendData "no"
If A = "#END#" Then
For I = 0 To Len(FMain.TIn.Text)
If I 100 Then
W = Left(Right(FMain.TIn.Text, I), 1)
If W = "!" Then
W = Left(Right(FMain.TIn.Text, I + 4), 5)
Exit For
End If
Else
Exit For
End If
Next I
If W "下载完成!" Then
FOK = False
Me.Caption = "下载完成![" Text2.Text "]"
FMain.TIn.Text = FMain.TIn.Text "[" Now "]" "下载完成!(" Fs "=" LenFile ")" vbCrLf
Command2.Enabled = True
End If
Else
If Val(Temp) = J Then '比较长度看丢包没有
ReDim MendByte(J - 8)
For I = 0 To J - 8 '提出包头
MendByte(I) = FileByte(I + 7)
Next
Fs = Fs + UBound(FileByte) - 7
Put #FileNumber, , MendByte '写文件
Winsock0.SendData "ok" '发送继续发送的请求
Me.Caption = "文件下载完成:[" Left(Fs / LenFile * 100, 4) "%]"
Else
If Left(A, 10) = "#SEND STA#" Then
A = ""
For I = 10 To UBound(FileByte) '文件发送结束标记
A = A Chr(FileByte(I))
Next
LenFile = Val(Left(A, InStr(A, "//") - 1))
For I = 0 To Len(Text2.Text)
A = Left(Right(Text2.Text, I), 1)
If A = "\" Then Exit For
Next
If Dir(Left(Text2.Text, Len(Text2.Text) - I + 1), vbDirectory) = "" Then MkDir Left(Text2.Text, Len(Text2.Text) - I + 1)
'"#SEND STA#" FileLen(Text1.Text) "//" Text2.Text
FileNumber = FreeFile '取得未使用的文件号
Fs = 0
Open Text2.Text For Binary As #FileNumber '打开文件
Else
If A "#SEND END#" Then
Winsock0.SendData "no" '出现丢包,请求重发
Else
Winsock0.SendData "#END#" '发送继续发送的请求
Close #FileNumber
Reset
If FOK = False Then
FOK = True
Me.Caption = "下载完成![" Text2.Text "]"
FMain.TIn.Text = FMain.TIn.Text "[" Now "]" "下载完成!(" Fs "=" LenFile ")" vbCrLf
Command2.Enabled = True
Else
FOK = False
End If
End If
End If
End If
End If
End Sub
语句InStr(2,"abcabc","ab")的功能就是,从字符串"abcabc"左起第2个字符开始,查找字符串
"ab",如果找到就返回匹配的左起的字符位置。
现在从字符串"abcabc"左起第2个字符开始,查找字符串"ab",找到的是第4位与第5位构成的“ab”,所以返回的是4。
这里的4是指,匹配的字符串在原来字符串里左面数起的位置。
例如:
Instr(2,"中国江苏南京","江苏") 返回3
Instr(1,"中国江苏南京","江苏") 返回3
Instr(2,"中国江苏南京","南京") 返回5
Instr(1,"中国江苏南京","苏南") 返回4
C#查找字串中指定字符或字串首次出现的位置用IndexOf()。
IndexOf()查找字串中指定字符或字串首次出现的位置,返首索引值,如:
str1.IndexOf("字") //查找“字”在str1中的索引值(位置)
str1.IndexOf("字串") //查找“字串”的第一个字符在str1中的索引值位置
str1.IndexOf("字",start,end)//从str1第start+1个字符起,查找end个字符,查找“字”在字符串STR1中的位置[从第一个字符算起]
注意:start+end不能大于str1的长度 indexof参数为string,在字符串中寻找参数字符串第一次出现的位置并返回该位置。