Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

VBScript string functions in Qlikview?

I am having a bit of a problem using some common string functions - instr and left, in particular.  I am reading in a variable value, and want to find the location of the dash in the string, and then display the first X number of characters in the string, up to the dash.

For example:  variable = 334-545

I want the message box to display 334

My code is :

set BandOne = ActiveDocument.Variables("Variable1").getContent
set BandTwo = ActiveDocument.Variables("Variable2").getContent

DashLoc = instr(1, BandOne, "-")
msgbox(left(BandOne, DashLoc))

The code is stopping on the DashLoc location, saying "type mismatch".  What am I doing wrong?

 

Thanks

1 Solution

Accepted Solutions
erichshiino
Partner - Master
Partner - Master

The functions is fine, just need to handle the variables in a different way

sub inString

dim DashLoc

set BandOne = ActiveDocument.Variables("Variable1")

set BandTwo = ActiveDocument.Variables("Variable2")

DashLoc = instr(1, BandOne.GetContent.String, "-")-1

msgbox(left(BandOne.GetContent.String, DashLoc))

end sub

View solution in original post

4 Replies
llauses243
Creator III
Creator III

Hi,

function INSTR not exists, to use ...

subfield(S, ';' ,2)

returns 'cde' if S is 'abc;cde;efg'


foor more detail see help

good luck, Luis.

Not applicable
Author

Thanks, Luis, but that's not the right function.  That is to be used inside either an action or in the load script.  I am looking for something that will function in a macro.

erichshiino
Partner - Master
Partner - Master

The functions is fine, just need to handle the variables in a different way

sub inString

dim DashLoc

set BandOne = ActiveDocument.Variables("Variable1")

set BandTwo = ActiveDocument.Variables("Variable2")

DashLoc = instr(1, BandOne.GetContent.String, "-")-1

msgbox(left(BandOne.GetContent.String, DashLoc))

end sub

Not applicable
Author

Erich...  Thank you, thank you!  I am having a bit of a hard time getting my head around the syntax here.