Re: Finding out if array has been dimensioned??
From: Howard Kaikow (kaikow_at_standards.com)
Date: 08/18/04
- Next message: Greg Maxey: "Re: Sticky Boolean"
- Previous message: Peter Hewett: "Re: Multiple Selections from ComboBox"
- In reply to: JB: "Re: Finding out if array has been dimensioned??"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Aug 2004 07:18:27 -0400
You have to redim the array to the appropriate size before you start reading
the file.
But how do you know the number of elements in the file?
If you cannot redim in advance and you will have to do a redim preserves as
many times as is necessary.
-- http://www.standards.com/; See Howard Kaikow's web site. "JB" <no@way.com> wrote in message news:OguKiWTgEHA.3192@tk2msftngp13.phx.gbl... > Helmut Weber wrote: > > Hi JB, > > hm..., I wonder, > > with "option explicit" code shouldn't run at all, if a variable > > wasn't declared (dim) . Without "option explicit", the variable is > > dimensioned (declared) at runtime. What are the conditions, that > > prevent the declaration? Or am I missing the point, and you want to > > know, if the array, that didn't have an index, was redimensioned? > > Then, have a look at this: > > ' option explicit > > ----- > > Dim MyArray() As String > > On Error Resume Next > > MsgBox UBound(MyArray) > > If Err.Number = 9 Then > > MsgBox "no index" & Chr(13) & _ > > Err.Description > > End If > > > > --- > > Greetings from Bavaria, Germany > > Helmut Weber, MVP > > "red.sys" & chr(64) & "t-online.de" > > Word XP, Win 98 > Yeah Helmut..Sorry that's what I meant. > > I thought there might have been a handy function like IsArray (I know > this is different) that could tell me if the array had an index? > > It's the ReDim portion that I'm having trouble with as I'm trying to > write a text file with values from the doc custom styles and populate a > listbox with the custom style values. > > Problem is when I come accross a doc that has no custom styles <g> > > On Error GoTo CloseFile > > count = UBound(aStyArrName()) + 1 'here if no index falls over!! > > Open filename For Output As #filenumber > > Print #filenumber, "[Setup]" > Print #filenumber, "TemplateName=" & frmStyles.txtTemplateName > Print #filenumber, "Count=" & count > Print #filenumber, "" > > For i = 0 To count - 1 > Print #filenumber, "[Style" & " " & i + 1 & "]" > Print #filenumber, "Name=" & aStyArrName(i) > Print #filenumber, "Size=" & aStyArrSize(i) > Print #filenumber, "FontType=" & aStyArrFont(i) > Print #filenumber, "StyleType=" & aStyArrStyleType(i) > Print #filenumber, "" > Next > CloseFile: > Close #filenumber > > frmStyles.lstStyleNames.Clear > count = UBound(aStyArrName()) + 1 > For i = 0 To count - 1 > frmStyles.lstStyleNames.AddItem aStyArrName(i) > Next > > etc......... > > Any pointers? > > J > >
- Next message: Greg Maxey: "Re: Sticky Boolean"
- Previous message: Peter Hewett: "Re: Multiple Selections from ComboBox"
- In reply to: JB: "Re: Finding out if array has been dimensioned??"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading