Solved

Help with my array...

Posted on 2004-10-12
4
234 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
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
bkthompson2112 earned 200 total points
Comment Utility
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 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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
Comment Utility
Great - now can I get some help on this far stranger problem?
http:Q_21165122.html
0
 
LVL 6

Expert Comment

by:bkthompson2112
Comment Utility
Thanks :)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now