首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > 代码乐园 >
    7i24 .Com  
  两个字符串的处理函数

7i24.Com不停为您服务
两个字符串的处理函数

<%
' =================================================================
' Reformat "txtName" to proper case.
' EX: "jason smith" to "Jason Smith"
' =================================================================
Function Proper(txtName) 
  Dim txtRest, txtTmp, intSpcPos
  txtRest = LCase(txtName)  
  intSpcPos = InStr(1, txtRest, " ")
  Do While intSpcPos <> 0
    txtTmp = txtTmp & UCase(Left(txtRest, 1)) & Mid(txtRest, 2,
(intSpcPos - 1))
    txtRest = Mid(txtRest, intSpcPos + 1, Len(txtRest))
    intSpcPos = InStr(1, txtRest, " ")  
  Loop
  Proper = txtTmp & UCase(Left(txtRest, 1)) & Mid(txtRest, 2,Len
(txtRest))
End Function
' =================================================================
%>




<%
' =================================================================
' Reformat "txtName" to proper case.
' Output = String
' =================================================================
Function Proper(txtName) 
  Dim txtRest, txtTmp, intSpcPos
  txtRest = LCase(txtName)
  
  'Single Quote
  intTckPos = InStr(1, txtRest, "'",1)
  if intTckPos <> 0 then
    txtTmp = UCase(Mid(txtRest, intTckPos + 1, 1))
    txtRest = Left(txtRest, intTckPos) & txtTmp & Mid(txtRest,
intTckPos + 2, Len(txtRest))
    txtTmp = ""
  end if
  
  'Hypenated
  intDshPos = InStr(1, txtRest, "-",1)
  if intDshPos <> 0 then
    txtTmp = UCase(Mid(txtRest, intDshPos + 1, 1))
    txtRest = Left(txtRest, intDshPos) & txtTmp & Mid(txtRest,
intDshPos + 2, Len(txtRest))
    txtTmp = ""
  end if
  
  'MC
  intMcPos = InStr(1,txtRest,"mc",1)
  if intMcPos <> 0 then
    txtTmp = UCase(Mid(txtRest, intMcPos+2, 1))
    txtRest = Left(txtRest, intMcPos+1) & txtTmp & Mid(txtRest,
intMcPos+3, Len(txtRest))
    txtTmp = ""
  end if
  
  'Space
  intSpcPos = InStr(1, txtRest, " ")
  Do While intSpcPos <> 0
    txtTmp = txtTmp & UCase(Left(txtRest, 1)) & Mid(txtRest, 2,
(intSpcPos - 1))
    txtRest = Mid(txtRest, intSpcPos + 1, Len(txtRest))
    intSpcPos = InStr(1, txtRest, " ")  
  Loop
  
  'Output
  Proper = txtTmp & UCase(Left(txtRest, 1)) & Mid(txtRest, 2,Len
(txtRest))
End Function
' =================================================================
%> 


  2002年1月9日  阅读 772 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 检测提交数据的函数
下一篇: 测试字符串是否为big或big5码
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利