Hjælp til Array
Hej jeg har kodet mig frem til noget som virker, men jeg tror ikke på det er optimalt - så håber der en der kan hjælpe/gennemskue det og komme med kommentar.<%
' I min verden skal det se sådan ud her...
'
' arrID FieldName FieldType Required DBFieldName
' ---------------------------------------------------------------------------
' 0 Name input yes Name
' 1 Address input yes Address
' 2 City input yes City
' 3 Zip input yes zip
' 4 email input yes email
' 5 InfoBox textarea no infor
dim strFieldNames, arrFieldNames, strFieldCols, arrFieldCols
strFieldCols = "FieldName,FieldType,Required,WinkompasFieldName"
arrFieldCols = split(strFieldCols,",")
x = ubound(arrFieldCols)
strFieldNames = strFieldNames & "Firma:,Input,no,Company" & vbTab
strFieldNames = strFieldNames & "Navn:,Input,yes,Name" & vbTab
strFieldNames = strFieldNames & "Adresse:,Input,yes,Addess1" & vbTab
strFieldNames = strFieldNames & "Postnr.,Input,yes,Zip" & vbTab
strFieldNames = strFieldNames & "By:,Input,yes,City" & vbTab
strFieldNames = strFieldNames & "Email:,Input,yes,Email" & vbTab
strFieldNames = strFieldNames & "Telefon:,Input,yes,Phone" & vbTab
strFieldNames = strFieldNames & "Notat:,Input,no,Remark" & vbTab
arrFieldNames = split(strFieldNames,vbTab)
y = ubound(arrFieldNames)
Dim myArray()
redim myArray(x,y)
for each objItem in arrFieldNames
i = i + 1
arrField = split(objItem,",")
For t = LBound(arrField) to UBound(arrField)
myArray(0,i) = arrField(0)
myArray(1,i) = arrField(1)
myArray(2,i) = arrField(2)
myArray(3,i) = arrField(3)
Next
next
Response.Write "<table border='0'>"
Response.Write "<tr><td>ID</td><td>FeltNavn</td>"
Response.Write "<td>FeltType</td><td>Required</td><td>DBFieldName</td></tr>"
'In our code below you'll notice UBound(myArray,2).
'The 2 is an optional parameter, it identifies which
'dimension of the array you want to find the highest element of.
'In this case 2 signifies the rows dimension
'1 is the default and would apply to the columns
'the highest element in the row column in this case is 3
'so we could look on our loopcounter going from 0 to 3 i.e. For i=0 to 3
'ArrayDimension defaults to 1, so if you are checking a 1 dimensional array or
'you want to check the first dimension you can leave this out.
For i = 0 to UBound(myArray,2)
Response.Write "<tr><td>" & i & "</td>"
Response.Write "<td>" & myArray(0,i) & "</td>"
Response.Write "<td>" & myArray(1,i) & "</td>"
Response.Write "<td>" & myArray(2,i) & "</td>"
Response.Write "<td>" & myArray(3,i) & "</td></tr>"
Next
Response.Write "</table>"
%>
