How to use Replace function in VBScript

后端 未结 1 1069
无人及你
无人及你 2021-01-20 16:23

I don\'t know why this code doesn\'t work:

Dim a
a = InputBox(\"What time do you want?\")
If InStr(a, \"pm\") Then
  (Replace(a, \"pm\", \"\"))
  a = a + 12
         


        
相关标签:
1条回答
  • 2021-01-20 17:16

    When you try to run that code you should get the following error

    Microsoft VBScript compilation error: Expected statement
    Line 4

    which will lead you to the culprit which is

    (Replace(a, "pm",""))
    

    which isn't a valid statement in VBScript hence the error.

    Based on what you are trying to do the script needs to return the result of the Replace() function call, something like this

    a = Replace(a, "pm","")
    
    0 讨论(0)
提交回复
热议问题