List Boxes #2

Can someone tell me how to correct the following code so that both
columns in the listbox will be updated?  Only the first column
distplays

Dim MyArray()
ReDim MyArray(mycount, 1)
usrGLDist.lstOutput.ColumnCount = 2

   For i = 0 To rst.Count - 1
        MyArray(i, 0) = rst.Value("descr")
        MyArray(i, 1) = rst.Value("pcamt")
    rst.MoveNext
   Next i

    'Load ListBox1
    usrGLDist.lstOutput.List() = MyArray

0
6/13/2011 10:10:43 PM
excel 39879 articles. 2 followers. Follow

4 Replies
558 Views

Similar Articles

[PageSpeed] 28

Richard wrote :
> Can someone tell me how to correct the following code so that both
> columns in the listbox will be updated?  Only the first column
> distplays
>
> Dim MyArray()
> ReDim MyArray(mycount, 1)
> usrGLDist.lstOutput.ColumnCount = 2
>
>    For i = 0 To rst.Count - 1
>         MyArray(i, 0) = rst.Value("descr")
>         MyArray(i, 1) = rst.Value("pcamt")
>     rst.MoveNext
>    Next i
>
>     'Load ListBox1
>     usrGLDist.lstOutput.List() = MyArray

You can't use ReDim on a multi-dim array. Change the code as follows...

  Dim MyArray(mycount, 1)

...where (I presume) mycount=rst.Count-1.

-- 
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


0
gs3102 (378)
6/14/2011 4:33:17 PM
> You can't use ReDim on a multi-dim array.

????  Try this code...

Sub Test()
  Dim First As Long, Second As Long
  First = 4
  Second = 9
  ReDim MyArray(First, Second)
  MsgBox "Lower Bound: " & UBound(MyArray, 1) & vbLf & _
         "Upper Bound: " & UBound(MyArray, 2)
End Sub

Rick Rothstein (MVP - Excel)
0
6/14/2011 5:42:42 PM
> MsgBox "Lower Bound: " & UBound(MyArray, 1) & vbLf & _
>         "Upper Bound: " & UBound(MyArray, 2)

Rather than say "Lower Bound" and "Upper Bound", that should have been 
"First Element Upper Bound" and "Second Element Upper Bound". Forget that 
though... here is a more complete demonstration.

Sub Test2()
  Dim LFirst As Long, UFirst As Long, LSecond As Long, USecond As Long
  LFirst = 2
  UFirst = 7
  LSecond = 4
  USecond = 11
  ReDim MyArray(LFirst To UFirst, LSecond To USecond)
  MsgBox "First Element Lower Bound: " & LBound(MyArray, 1) & vbLf & _
         "First Element Upper Bound: " & UBound(MyArray, 1) & vbLf & _
         "Second Element Lower Bound: " & LBound(MyArray, 2) & vbLf & _
         "Second Element Upper Bound: " & UBound(MyArray, 2) & vbLf
End Sub

Rick Rothstein (MVP - Excel) 

0
6/14/2011 6:00:28 PM
After serious thinking Rick Rothstein wrote :
>> MsgBox "Lower Bound: " & UBound(MyArray, 1) & vbLf & _
>>         "Upper Bound: " & UBound(MyArray, 2)
>
> Rather than say "Lower Bound" and "Upper Bound", that should have been "First 
> Element Upper Bound" and "Second Element Upper Bound". Forget that though... 
> here is a more complete demonstration.
>
> Sub Test2()
>   Dim LFirst As Long, UFirst As Long, LSecond As Long, USecond As Long
>   LFirst = 2
>   UFirst = 7
>   LSecond = 4
>   USecond = 11
>   ReDim MyArray(LFirst To UFirst, LSecond To USecond)
>   MsgBox "First Element Lower Bound: " & LBound(MyArray, 1) & vbLf & _
>          "First Element Upper Bound: " & UBound(MyArray, 1) & vbLf & _
>          "Second Element Lower Bound: " & LBound(MyArray, 2) & vbLf & _
>          "Second Element Upper Bound: " & UBound(MyArray, 2) & vbLf
> End Sub
>
> Rick Rothstein (MVP - Excel)

Thanks, Rick! So the rule then *still is* that you can't ReDim a 
multi-dim array *after it's been dimensioned*, which is not the case in 
this OP's context. My bad for not paying attention to the fact that 
MyArray() was not dimensioned (thus not declared as a multi-dim array).

Otherwise, the posted code works for me using contrived values. 
Perhaps, then, rst.Value("pcamt") is empty, OR is not a valid field. 
(Assumes OP is working with a DB recordset)

The OP doesn't claim an error message so I wonder if the code is 
covered by an 'On Error Resume Next' statement?

Here's my test...

Private Sub UserForm_Initialize()
  Const iCnt As Integer = 3
  Dim vListItems() As Variant, i As Integer
  ReDim vListItems(iCnt, 1)
  For i = 0 To iCnt
    vListItems(i, 0) = "Col1: ListItem" & i
    vListItems(i, 1) = "Col2: ListItem" & i
  Next
  With Me.ListBox1
    .ColumnCount = 2: .List = vListItems
  End With
End Sub

Output to ListBox1:

  Col1: ListItem0   Col2: ListItem0
  Col1: ListItem1   Col2: ListItem1
  Col1: ListItem2   Col2: ListItem2
  Col1: ListItem3   Col2: ListItem3

-- 
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


0
gs3102 (378)
6/14/2011 7:22:17 PM
Reply:

Similar Artilces:

Outlook 2003 SP1 NDR Report with bad KB Article #2
Recently a user has reported that she receives the following NDR when sending out emails. Your message did not reach some or all of the intended recipients. Subject: 4th Annual Energy Tech Investor Forum Sent: 8/20/2007 1:12 PM The following recipient(s) could not be reached: 'Christopher Lord' on 8/20/2007 1:12 PM None of your e-mail accounts could send to this recipient. Doing a search in the KB brings up article ID 872896... I checked back with the user, and yes on the emails sent out, the FROM line is empty. She authenticates to the SMTP serv...

Public folder delegation with Public Folder Settings Wizard #2
I'm having a problem with the Public Folder Settings Wizard that came available after SP2 installation. In the root of the public folder I've create a folder for every department, and they can do everything within their own folder. But after SP2 installation the management of public folders is changed and the delegated administrators cannot start the public folder settings wizard. This is probably a permissions issue, does anyone know what the minimal permissions are to start the Public Folder Settings Wizard? ...

How zoom/increase font size of Office 2004 "Help" text? #2
Font sizes can be set for Word, Excel and Entourage. You also can zoom in to enlarge the View of text in Office 2004 components´┐Ż documents. How does one do this with the small-font text in Help? Respectfully, Norm (The original of this post was "lost" to the newsgroup and is now being re-sent.) On 9/14/04 5:57 PM, in article BD6CE16D.4A37%nnager@vnoxsxpxaxmv.fullerton.edu, "Norman R. Nager, Ph.D." <nnager@vnoxsxpxaxmv.fullerton.edu> wrote: > > (The original of this post was "lost" to the newsgroup and is now being > re-sent.) > It wasn...

Selecting a line from a drop-down list
I have a table of data spread over four columns, with the keyword in th first column. What I want to do is select the required keyword from drop-down list, and have the other related information in the othe three cells automatically fill the required fields. For example, the data would be in an array from A3 to D10, and would b hidden so the user cannot see it. The selection fields are in an arra from A1 to D1. If I put a drop-down selection list in A1 which is se to choose from A3 to A10, how do I make the rest of the row autofil into the cells B2 to D2? I hope somebody can understand ...

Replace Exchange Server #2
I need to replace my Exchange Server. What's the best way to do this? Is there a way that I can do this and still maintain the name of my current server on the new server (obviously not at the same time). Andy On Mon, 23 Oct 2006 08:29:02 -0700, Andy Siegel <AndySiegel@discussions.microsoft.com> wrote: >I need to replace my Exchange Server. What's the best way to do this? Is >there a way that I can do this and still maintain the name of my current >server on the new server (obviously not at the same time). > >Andy Replace it with what? I am actually...

Sender receives 5.2.3 even after checking all size limits
Exchange 2003 SP2 on Windows Server 2003 SP1. I have checked everything in KB 322679: Global settings; connector settings; SMTP virtual server settings; mailbox settings but a sender outside the organization still keeps getting a message back from the Exchange server with error 5.2.3 with text "This message is larger than the current system limit or the recipient's mailbox is full. Create a shorter message body or remove attachments and try sending it again.". What else do I need to check? Kevin Kevin, What is the size of the message send by that outsider? and what is the...

Audit Trail #2
I'm looking for a report that shows the creator, approver and poster of batches on the general ledger. I've looked within Great Plains and found nothing. I located this sql table (PM80100) that contains the creator and approver of purchasing batches but I've been unsuccessful with a similar one for the general ledger. Any leads would be very helpful. Thanks! Possibly in FRx? "maatthias" wrote: > I'm looking for a report that shows the creator, approver and poster of > batches on the general ledger. I've looked within Great Plains and found &g...

any way to get a Public folder Calendar to show in Calendar lists?
Hi all, having users that it would be far easier if I could set up so that a Public Folder calendar shows up in their Calendars list in Calendar view in Outlook 2003. Is there any way to do this? TIA - Dodge On Thu, 19 Jan 2006 12:14:02 -0800, "Dodge" <Dodge@discussions.microsoft.com> wrote: >Hi all, having users that it would be far easier if I could set up so that a >Public Folder calendar shows up in their Calendars list in Calendar view in >Outlook 2003. Is there any way to do this? TIA - Dodge Choose "OPen a Shared Calendar" in Outlook. Browse to ...

Password Authentication #2
Guys, I'm having a problem where a user is getting prompted for a password, when he is already logged onto the network. He's already been authenticated, but when he hits send/receive, a window pops up for username/domain name/password. When he hits cancel, it successfully checks for mail anyway. When he hits send/receive again, the window doesn't pop up and it still works. Any ideas? RK. ...

Need Help #2
Hello... I Am new to dynamic Gp... i need to know how i can generate a cash report weekly, and how i can see where my revenue is recorded by monthly.... i mean cash on hand monthly... if any1 help me out i shall be very much thankful.... ...

Filling Area Between 2 Series in a Line Chart
Hello- I have a chart with two series; one plotted on the Primary Axis (assets-positive values), one on the Secondary Axis (liabilities-negative values). There is an area between the two lines that I would like to fill with a color or pattern (this will represent the "free cash" that is available). Is it possible to have this area filled? Thank you, Tom Tom - You'd need the data on the same axis. Plot it as a stacked area type chart, where the first series is Liabilities and the second is Assets - Liabilities (but named Assets). Format Liabilities to have a border a...

Color Coded Dropdown Lists
I was wondering if anyone could tell me if it was possible to color cod a dropdown list for a cell. The dropdown lists start at B3 an continue out for the rest of the sheet and down to B46. There are nin different subjects to choose from in the dropdown list that I nee color coded so that we can have a quick visual overview just by lookin at the sheet. Thanks much in advance : -- Message posted from http://www.ExcelForum.com Ok, I've changed the dropdown list to reference colored cells, but whe I choose a category from the list, I can't get the color formatting t follow through to...

Office Contacts List
Hello How do I create a contacts list that all company emaployee's can see and send emails form in OWA. I tried to setup contacts under public folders but I can't email from public folders in OWA and when I create a new message in OWA and goto to I cant search the public folders contacts. The public folders works great in Outlook but not so great on the web. Thanks for the help!!! "Tom McManus" <anonymous@discussions.microsoft.com> wrote: >How do I create a contacts list that all company >emaployee's can see and send emails form in OWA. Add the C...

OWA Contacts don't show in 'Send To' list
I'm currently using the WebDAV exchange interface to add contacts from our internal application, much the same as OWA does. If an email address is specified when the contact is added/updated (proppatch), the contact shows in the 'send to' dialog (addressing emails/faxes). If not, the contact is not shown. However, if I supply at least a Display Name on the email, the contact will appear in the send to dialog. Unfortunately, when I use the latter workaround, the MS Fax wizard (ships with windows xp or office xp, one or the other I think) throws an error about 'cannot resolve t...

formula question #2
I have a column of 0's and 1's. I need a formula to change the 1's to "yes" and the 0's to "no". Thanks for your help. Tim Hi why not use Edit-Replace? -- Regards Frank Kabel Frankfurt, Germany Tim wrote: > I have a column of 0's and 1's. I need a formula to change > the 1's to "yes" and the 0's to "no". > > Thanks for your help. > Tim Tim If you don't want to actually change them, but change the way they are displayed, you could use a custom format >Cells...>Number>Custom and type ...

CRM desktop client #2
is there any type of visual indication from the CRM 3.0 desktop client that will notify a user that another user has logged on or has been logged on? -- life is only like a box of chocolates if you live it with your eyes wide shut not without writing an external tool to do that, i do not think. -- Kamal Hitari MBSS, MCNPS, MCTS 2B.net Ltd http://kamalhitari.blogspot.com Joe B wrote: > is there any type of visual indication from the CRM 3.0 desktop client that > will notify a user that another user has logged on or has been logged on? ...

Combine 2 Money files into 1
I'm wondering if there is any way to combine 2 seperate files into one file. The only way that I can see to do it is to export thr accounts into QIf then import thrm back in. The only disadvantage to that is that i can't export any Loans and liability accounts. I'm running Money 2004 Thanks for the Help In addition When I import the QIF files it throws off the total amounts in the accounts >-----Original Message----- >I'm wondering if there is any way to combine 2 seperate >files into one file. The only way that I can see to do >it is to export thr ac...

Microsoft Office 2010 Reaches Technical Preview #2
On 13-July-09, at its Worldwide Partner Conference, Microsoft Corp. announced Office 2010, SharePoint Server 2010, Visio 2010 and Project 2010 have reached the technical preview engineering milestone. Starting today, tens of thousands of people will be invited to test Office and Visio as part of the Technical Preview program. <http://www.iclarified.com/entry/index.php?enid=4506> No mention of a Mac version ...

adding 2 columns where
Column B I have types of payments, google, amazon, paypal etc. column C contains $$ amounts. I want to add the money in column C where column B = paypal. what is the statement?? thank you!! See your other post -- Biff Microsoft Excel MVP "Tammy" <Tammy@discussions.microsoft.com> wrote in message news:0F795D87-AE43-45FA-9937-81D1B9AD1A28@microsoft.com... > Column B I have types of payments, google, amazon, paypal etc. > column C contains $$ amounts. > > I want to add the money in column C where column B = paypal. > > what is the statement?? > > t...

import contact list from comcast to outlook
how do you import your contacts from Comcast email to Outlook. Please help Richard A google search using the term "comcast.net export contacts" will provide the answer One of many pages related to the question that will appear in the results: How To Export Your Address Book From Comcast Webmail http://www.watchingthenet.com/export-address-book-contacts-from-comcast-webmail.html As a reference, this may also provide some insight to the question posed How do I import from ??? in Outlook http://www.contactgenie.com/blog/?p=185 Karl -- _________________________...

Online Updates #2
Just installed Money 2004. Setup online services. Told it NOT to download any old transactions. All of the sudden a few days later, when I do a online update it tells me I have several transactions to look at. When I go to the account, it don't show any new transactions. Whats up with that? In microsoft.public.money, S. Proctor wrote: >Just installed Money 2004. Setup online services. Told >it NOT to download any old transactions. All of the >sudden a few days later, when I do a online update it >tells me I have several transactions to look at. When I >...

Testing #2
Sorry for wasting space, I've been having trouble posting ...

Save as Msg box
I have the follwowing to save as a form: Sub SaveAs() ' ChDir "V:\Netshare\Item Master Creation\2005 Item Request Submission" Do fName = Application.GetSaveAsFilename Loop Until fName <> False ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=xlNormal End Sub Problems: 1. It doesn't go to the directory that I have above: "V:\Netshare\Item Master Creation\2005 Item Request Submission" 2. I want to enter a message box that confirms that yes they want to save after they have entered the name in the save as box. In the Excel hlp I was just ...

Leading zero is suppressed when I merge 2 cells
When i merge two cells i get this example: A1 B1 C1 124 05 1245 What I want is this: A1 B1 C1 124 05 12405 I used this formula to merge A1 & B1 but it supresses the leading zeros in column B Hi Jeff i'm guessing its because the 05 is displayed through cell formatting (custom number format of "00") rather than actually being there in the cell .. in this case try =A1 & text(b1,"00") Cheers JulieD "Jeff" <anonymous@discussions.microsoft.com> wrote in message news:396501c49c0a$d3b384a0$a501280a@phx....

Distribution List
Hi Our GAL has a number of Distribution Lists. Right now, all the DLs are visible and accessible by everyone in Exchange. Is it possible to set up so that a particular DL can only be visible to a specific user (or group of users) ? Thanks Steve ...