Solved

Help with my array...

Posted on 2004-10-12
4
236 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
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 85

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

770 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