vb函数String(MCIStatusLen + 1, " ")长度和字符返回问题?

来源:百度知道 编辑:UC知道 时间:2024/09/28 09:24:36
1,一个变量初始化定义如下:
MCIStatusLen = 15
MCIStatus = String(MCIStatusLen + 1, " ")

2,后面返回MCIStatus值是"stopped ",我用Len(MCIStatus), Replace(Trim(MCIStatus), " ", ""),
返回结果依然是:
Len(MCIStatus)=16
Replace(Trim(MCIStatus), " ", "")="stopped ",有什么函数可以让它的长度是返回值的长度?
1.贴代码:
'如要目的就是让MCIStatus = "stopped"这句返回也是True?
Private Sub Timer1_Timer()
Dim strTitle As String
Dim hdl As Long
Dim MCIStatusLen As Integer
Dim MCIStatus As String
If IsMusicOn = True Then
MCIStatusLen = 15
MCIStatus = String(MCIStatusLen + 1, " ")
RetValue = mciSendString("STATUS BackgroundMusic MODE", MCIStatus, MCIStatusLen, 0)
End If
strTitle = Space(765)
hdl = GetForegroundWindow
GetWindowText hdl, strTitle, 1024
Debug.Print Left(Replace(strTitle, " ", ""),

如果你要获得的是Replace(Trim(MCIStatus), " ", "")的长度,那么:

len(Replace(Trim(MCIStatus), " ", ""))就是这个长度了

你描述的有点不太清楚
---------------------------
改成这样:
If Left(Replace(strTitle, " ", ""), 9) = "Messenger" And Trim(MCIStatus) = "stopped" Then '这句是关键

你不如把你自己的代码贴出来~注释下哪句需要哪个效果。