vbmid函数的使用方法
展开全部
从贴出来的图片看,与Mid()函数无关。
Mid("abcde",2,2) ——"bc" Mid("abcde",2) ——"bcde"
MSDN,最好的示例:
Dim MyString, FirstWord, LastWord, MidWords
MyString = "Mid Function Demo" ' Create text string.
FirstWord = Mid(MyString, 1, 3) ' Returns "Mid".
LastWord = Mid(MyString, 14, 4) ' Returns "Demo".
MidWords = Mid(MyString, 5) ' Returns "芹启亮Function Demo".
The second example use MidB and a user-defined function (MidMbcs) to also return characters from string. The difference here is that the input string is ANSI and the length is in bytes.
Function MidMbcs(ByVal str as String, start, length)
MidMbcs = StrConv(MidB(StrConv(str, vbFromUnicode), start, length), vbUnicode)
End Function
Dim MyString
MyString = "AbCdEfG"
' Where "A", "C"旁枝, "嫌宽E", and "G" are DBCS and "b", "d",
' and "f" are SBCS.
MyNewString = Mid(MyString, 3, 4)
' Returns ""CdEf"
MyNewString = MidB(MyString, 3, 4)
' Returns ""bC"
MyNewString = MidMbcs(MyString, 3, 4)
' Returns "bCd"
Mid("abcde",2,2) ——"bc" Mid("abcde",2) ——"bcde"
MSDN,最好的示例:
Dim MyString, FirstWord, LastWord, MidWords
MyString = "Mid Function Demo" ' Create text string.
FirstWord = Mid(MyString, 1, 3) ' Returns "Mid".
LastWord = Mid(MyString, 14, 4) ' Returns "Demo".
MidWords = Mid(MyString, 5) ' Returns "芹启亮Function Demo".
The second example use MidB and a user-defined function (MidMbcs) to also return characters from string. The difference here is that the input string is ANSI and the length is in bytes.
Function MidMbcs(ByVal str as String, start, length)
MidMbcs = StrConv(MidB(StrConv(str, vbFromUnicode), start, length), vbUnicode)
End Function
Dim MyString
MyString = "AbCdEfG"
' Where "A", "C"旁枝, "嫌宽E", and "G" are DBCS and "b", "d",
' and "f" are SBCS.
MyNewString = Mid(MyString, 3, 4)
' Returns ""CdEf"
MyNewString = MidB(MyString, 3, 4)
' Returns ""bC"
MyNewString = MidMbcs(MyString, 3, 4)
' Returns "bCd"
追问
额 弄错了 我想问的是贴图的问题 就是那个时间16两边怎么又空格 还有星期2的2怎么写成二
追答
最好是写成一个字符串的形式,如下:
Private Sub Command1_Click()
Print "现在的时间是:" & Year(Now) & "年" & Month(Now) & "月" & Day(Now) & "日" & _
"星期" & Choose(Weekday(Now), "日", "一", "二", "三", "四", "五", "六") & _
Hour(Now) & "时" & Minute(Now) & "分" & Second(Now) & "秒"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询