VB6.0 String 用法总结

问题一 VB 去掉字符串的头尾的空格

使用trim()

如: trim(" hello world ")= "hello world"

问题二 判断一个字符串是否是 一行空格

解决方法,去掉头部和尾部的所有空格没然后,得到新的字符串,看此字符串的长度

使用Len 得到长度

转载于:https://www.cnblogs.com/zanglaowei/p/4822275.html

首先:Imports System.Runtime.InteropServices 然后: Private Declare Function EbExecuteLine Lib "VBA6.DLL" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long ' <DllImport("VBA6.DLL", EntryPoint:="EbExecuteLine", SetlastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> Public Shared Function EbExecuteLine(ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long '<DllImport("D:\vba6.dll", CharSet:=CharSet.Ansi, SetlastError:=True)> Public Shared Function EbExecuteLine(ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long 'End Function '<DllImport("vba6.dll", CharSet:=CharSet.Ansi, SetlastError:=True)> 'Public Shared Function EbExecuteLine(ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long 'End Function '定义StrPtr函数,实现获取字符串地址功能 Private Function StrPtr(ByVal e As Object) As Int32 Dim GC As System.Runtime.InteropServices.GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(e, System.Runtime.InteropServices.GCHandleType.Pinned) Dim GC2 As Int32 = GC.AddrOfPinnedObject.ToInt32 GC.Free() Return GC2 End Function Function ExecuteLine(ByVal sCode As String, Optional ByVal fCheckOnly As Boolean = True) As Boolean ExecuteLine = EbExecuteLine(StrPtr(sCode), 0, 0, 0) End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dm() As String Dim i As Long dm = Split(TextBox.Text, ";") For i = 0 To UBound(dm) If Len(dm(i)) <> 0 Then Dim Result As Boolean Result = ExecuteLine(dm(i)) If Result = False Then Debug.Print(i + 1 & vbTab & "行执行错误") Else Debug.Print(i + 1 & vbTab & "行代码错误") End If Next End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值