Convert data type with LS

Cannot find how to convert file fromat from text to textlist. See below. I am open to other suggestions too.

Do While Not Doc Is Nothing	

	strYear = Year(doc.Date(0))	 & "-" & Format(Month(doc.Date(0))	, "00")			

	If doc.region(0) <> strKey(0) Then Exit Do

	If  strYear <> strKey(2) Then Exit Do

	

	strStb = doc.ColumnValues(3)

	strStb = Split(strStb(0), "~") ---> see comments below 

	Redim Preserve patrlStubs(i) 	

	patrlStubs(i).LineSeg = strStb(0)

	patrlStubs(i).Day = strStb(1)

	patrlStubs(i).Prob = strStb(2)						

	i = i + 1

	Set doc = view.GetNextDocument(doc)		

Loop

This line is where the error has occured because the strStb has either Text or TextList data types. TextList works fine but Text isn’t.

The error message says “184:Variant does not contain a container”

How can I force the datatype from Text to TextList?

Subject: Convert data type with LS

I’m not sure if I’m answering your question but Split returns a Variant and not a String ( or Array of String ).

So try this:

Dim varStb As Variant



Do While Not Doc Is Nothing	

	strYear = Cstr(Year(doc.Date(0))) & "-" & Format(Month(doc.Date(0)), "00")			

	If doc.region(0) <> strKey(0) Then Exit Do

	If  strYear <> strKey(2) Then Exit Do

	

	strStb = doc.ColumnValues(3)

	varStb = Split(strStb(0), "~") 

	Redim Preserve patrlStubs(i) 	

	patrlStubs(i).LineSeg = varStb(0)

	patrlStubs(i).Day = varStb(1)

	patrlStubs(i).Prob = varStb(2)						

	i = i + 1

	Set doc = view.GetNextDocument(doc)		

Loop

Subject: RE: Convert data type with LS

Your suggestion did not work because strStb has already been defined as a variant. It must be something with the

Split(strStb(0), “~”)

The above line of code works with the data type textlist but not with just text.

Subject: Convert data type with LS

Resolution found. If anyone is looking for something similar, here is the code.

Dim strStb As Variant

Dim varStb As Variant



Do While Not Doc Is Nothing	

	strYear = Cstr(Year(doc.Date(0)))  & "-" & Format(Month(doc.Date(0)), "00")			

	If doc.region(0) <> strKey(0) Then Exit Do

	If  strYear <> strKey(2) Then Exit Do

	strStb = doc.ColumnValues(3)

	If  Not Isarray(strStb) Then

		varStb = Split(strStb, "~")	

	Else

		varStb = Split(strStb(0), "~")

	End If	

	Redim Preserve patrlStubs(i) 	

	patrlStubs(i).LineSeg = varStb(0)

	patrlStubs(i).Day = varStb(1)

	patrlStubs(i).Prob = varStb(2)						

	i = i + 1

	Set doc = view.GetNextDocument(doc)		

Loop