Solved

Help with my array...

Posted on 2004-10-12
4
239 Views
Last Modified: 2010-05-02
I seem to get hung up on arrays...

First of all, I have a label, when clicked, shows a date control (vbmodal).
Once the date is chosen, I want the month, day & year seperated.

In my click event, I currently have
        Dim intTemp() As Integer
        frmDate.Show vbModal
        ReDim intTemp(UBound(Split(dateClick, "/")))

Now, I have the 3 elements in my intTemp array, but I can't assign anything to them the way I would like.

Btw, I know the 'easy' answer is "declare intTemp as a variant", but I don't really want to go that route if unnecessary...
0
Comment
Question by:sirbounty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
bkthompson2112 earned 200 total points
ID: 12287440
Just a thought:

if you change
Dim intTemp() As Integer
to
Dim sTemp() As String

and change
ReDim intTemp(UBound(Split(dateClick, "/")))
to
sTemp = Split(dateClick, "/")

then sTemp(0) sTemp(1) and sTemp(2) would contain the 3 date parts.

If you later need then as ints, then use CInt(sTemp(0))

bkt
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12287451
The answer you don't want:

    Dim intTemp As Variant
    frmDate.Show vbModal
    intTemp = Split(dateClick, "/"))
    Debug.Print "Month = " & intTemp(0)
    Debug.Print "Day = " & intTemp(1)
    Debug.Print "Year = " & intTemp(2)

If you really want an array of Integer then:

    Dim intTemp(2) As Integer
    Dim strTemp As Variant
    frmDate.Show vbModal
    strTemp = Split(dateClick, "/"))
    intTemp(0) = CInt(strTemp(0))
    intTemp(1) = CInt(strTemp(1))
    intTemp(2) = CInt(strTemp(2))

~IM
0
 
LVL 67

Author Comment

by:sirbounty
ID: 12287492
Great - now can I get some help on this far stranger problem?
http:Q_21165122.html
0
 
LVL 6

Expert Comment

by:bkthompson2112
ID: 12287568
Thanks :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question