Solved

Help with my array...

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

839 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