VB如何定义b使len(text1.text)=len(b)
比如 开始定义变量 a as string*100,函数返回a=da0 1564(长度不确定100以内)
如何判断出a的 真真实长度?
再如何定义变量b,使b=a的有效字符?
要求等同效果:text1.text=a 从而使len(text1.text)=len(b)
不好意思 可能是我没说明白
Private Sub Command1_Click()
Dim a As Long,b As String * 100
a = FindWindow("Notepad",vbNullString)
GetWindowText a,b,101
print b
‘b的真实长度是多少?
End Sub
VB如何定义b使len(text1.text)=len(b)
答案:1 悬赏:0 手机版
解决时间 2021-08-16 01:25
- 提问者网友:像風在裏
- 2021-08-15 01:31
最佳答案
- 五星知识达人网友:封刀令
- 2021-08-15 01:51
Private Sub Command1_Click()
Dim a As String * 100
a = "da0 1564"
Print a
Print Len(Trim(a)) ' 用Trim消除空格再 Len()
End Sub
再问: 不好意思 我没说明白
再答: Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Sub Command1_Click() Dim a As Long, b As String * 100 a = FindWindow("Notepad", vbNullString) GetWindowText a, b, 101 Print b '检验 b Print Dim i As Integer For i = 1 To 100 Print Asc(Mid(b, i, 1)); If i Mod 10 = 0 Then Print Next '发现 b 包含 空格Chr(32) 和 Chr(0) '因此, 去空格, 去 Chr(0), 再 Len() Print Print "b的真实长度为", Len(RTrim(Replace(b, Chr(0), "")))End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯