---
title: "Array-problem"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/176520-array-problem"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "l-boy"
published: "2009-01-26T09:49:00.000Z"
updated: "2009-01-26T14:12:50.000Z"
replies: 16
views: 646
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/176520-array-problem"
---

# Array-problem

## #1 — l-boy, 2009-01-26T09:49Z

Använder en komponent som heter ABC PDF. En funktion i denna returnerar en "Array of Strings".

```

Dim tagIds
tagIds = theDoc.HtmlOptions.GetTagIDs(theID)
response.write ubound(tagIds)&"<br>"
response.write isarray(tagIds)
```

Ger mig:

5
true

Betyder inte detta att jag skall kunna köra en response.write tagIds(1) utan problem? Får nämligen felmeddelandet " Inkompatibla typer: 'tagIds' " ..

Vad är tokigt?

Permalänk: https://www.webforum.nu/p/176520

## #2 — Peter S, 2009-01-26T10:04Z

Vad ger lbound(tagIds)?

Permalänk: https://www.webforum.nu/p/2166579

## #3 — l-boy, 2009-01-26T10:05Z

Det ger 0

Permalänk: https://www.webforum.nu/p/2166580

## #4 — Eclipse, 2009-01-26T10:22Z

kolla varType i manualen.

```
Dim tagIds
tagIds = theDoc.HtmlOptions.GetTagIDs(theID)
response.write varType (ubound(tagIds) ) &"<br>"
response.write varType( isarray(tagIds) )
```

OK, eller denna då!? quick and dirty...

```
IF tagIds(0) <> "" THEN response.write tagIds(0) & "<BR>"
IF tagIds(1) <> "" THEN response.write tagIds(1) & "<BR>"
IF tagIds(2) <> "" THEN response.write tagIds(2) & "<BR>"
IF tagIds(3) <> "" THEN response.write tagIds(3) & "<BR>"
IF tagIds(4) <> "" THEN response.write tagIds(4) & "<BR>"
```

Permalänk: https://www.webforum.nu/p/2166585

## #5 — l-boy, 2009-01-26T10:25Z

vartype(tagids) = 8200 ...

Permalänk: https://www.webforum.nu/p/2166586

## #6 — Eclipse, 2009-01-26T10:28Z

<http://www.w3schools.com/vbScript/func_vartype.asp>

om du har ett nummer som inte finns i listan så blir det problem...

\*\*\*
Satsa på en åtta!

8 = vbString - Indicates a string

Cstr( tagIds(1) )

Permalänk: https://www.webforum.nu/p/2166588

## #7 — l-boy, 2009-01-26T10:30Z

8200:
returns 8192 + VarType(array_element). 
8 = vbString - Indicates a string 

Så det stämmer juh...

Permalänk: https://www.webforum.nu/p/2166589

## #8 — Eclipse, 2009-01-26T10:31Z

Det har du rätt i! Då är du på rätt spår!

Permalänk: https://www.webforum.nu/p/2166590

## #9 — l-boy, 2009-01-26T10:32Z

> **Eclipse skrev:**
>
> kolla varType i manualen.
> 
>
>
> ```
> Dim tagIds
> tagIds = theDoc.HtmlOptions.GetTagIDs(theID)
> response.write varType (ubound(tagIds) ) &"<br>"
> response.write varType( isarray(tagIds) )
> ```
>
> 
> 
> 
> OK, eller denna då!? quick and dirty...
> 
> 
>
>
> ```
> IF tagIds(0) <> "" THEN response.write tagIds(0) & "<BR>"
> IF tagIds(1) <> "" THEN response.write tagIds(1) & "<BR>"
> IF tagIds(2) <> "" THEN response.write tagIds(2) & "<BR>"
> IF tagIds(3) <> "" THEN response.write tagIds(3) & "<BR>"
> IF tagIds(4) <> "" THEN response.write tagIds(4) & "<BR>"
> ```

Inkompatibla typer: 'tagIds'
/pdf/default.asp, line 12

\#12 = IF tagIds(0) \<\> "" THEN response.write tagIds(0) & "\<BR\>"

Permalänk: https://www.webforum.nu/p/2166591

## #10 — l-boy, 2009-01-26T10:39Z

> **Eclipse skrev:**
>
> Cstr( tagIds(1) )

Inkompatibla typer: 'tagIds'

Permalänk: https://www.webforum.nu/p/2166592

## #11 — Peter S, 2009-01-26T11:12Z

Kan du loopa över arrayen med For Each?

```
For Each item In tagIds
  Response.Write item & "<br>"
Next
```

Permalänk: https://www.webforum.nu/p/2166599

## #12 — l-boy, 2009-01-26T11:17Z

Nope. 

"Inkompatibla typer" på första raden.

Permalänk: https://www.webforum.nu/p/2166600

## #13 — SPiN, 2009-01-26T11:35Z

Du verkar inte få någon array tillbaka från GetTagIDs(). Titta på typen av den:

```
Response.Write TypeName(tagIds)
If TypeName(tagIds) = "String" Then
   Response.Write tagIds
End If
```

Permalänk: https://www.webforum.nu/p/2166603

## #14 — l-boy, 2009-01-26T12:20Z

Response.Write TypeName(tagIds)
ger
String()

Men

Response.Write tagIds
Funkar inte.
(En ohanterad datatyp påträffades.)

Permalänk: https://www.webforum.nu/p/2166606

## #15 — Peter S, 2009-01-26T12:33Z

Du verkar inte vara ensam om problemet i alla fall: <http://forums.devshed.com/asp-programming-51/type-mismatch-when-working-with-arrays-130919.html>.

Problemet är att det är en String() som returneras medan VBScript vill ha en variant.

Permalänk: https://www.webforum.nu/p/2166608

## #16 — Eclipse, 2009-01-26T14:06Z

Ja... sista posten var intressant, citerad nedan.

Men hur gör man en EN-dimensionell array till en TVÅ-dimensionell? Utan att skriva siffror och bokstäver för hand!?

Ja.. det är i alla fall inte min hjärna kapabel att räkna ut i skrivande stund!

```
Public Function Test() As Variant

Dim f(0, 3) As Variant ' f(3) replaced here with f(0,3)

f(0, 1) = "a"
f(0, 2) = "b"
f(0, 3) = "c"

Test = f

End Function
```

Permalänk: https://www.webforum.nu/p/2166624

## #17 — Peter S, 2009-01-26T14:12Z

Förmodligen måste man skriva en wrapper för abcpdf-metoden som ser ut enligt ovan.

Permalänk: https://www.webforum.nu/p/2166628

---

Tråden på webben: https://www.webforum.nu/amne/asp/176520-array-problem
