Results 1 to 6 of 6

Thread: Why is it returning nothing?!?!?

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Unhappy

    I have this code piece to try and convert a month in numbers to the actual month like 11/ would be november. But I get a blank msgbox when I try this code and I can not figure out why! thanks for any help!

    Dim strdate As String
    Dim strmonth As String
    Dim theday As String
    Dim str2 As String
    Dim strday As String
    Dim chkmonth As String

    strdate = Text1.Text

    If Left$(strdate, 3) = "/" Then
    Select Case Mid(Text1.Text, 1, 2)
    Case "10"
    str2 = "October"
    Case "11"
    str2 = "November"
    Case "12"
    str2 = "December"
    End Select
    strmonth = str2
    End If
    MsgBox strmonth

    Matt

  2. #2
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    well the proble might lie in either ur if statement or at the end

    If Left$(strdate, 3) = "/" Then
    Select Case Mid(Text1.Text, 1, 2)
    Case "10"
    str2 = "October"
    Case "11"
    str2 = "November"
    Case "12"
    str2 = "December"
    End Select
    strmonth = str2
    End If
    MsgBox strmonth

    that last line is saying that if the months don't fall between oct or dec then give a message box of strmonth ...
    but no where on ur code is strmonth set to anything ...
    maybe u meant to put: msgbox str2 ???

  3. #3
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96
    The reason it was showing nothing was because left$ was returning "dd/" and not just /.

    The code below works

    Dim temp As String

    strdate = Text1.Text

    temp = Mid(strdate, 4, 2) ' Starts at position 4 in the
    ' string and returns the next 2
    ' chars i.e mm out of dd/mm/yy

    Select Case temp
    Case "10"
    str2 = "October"
    Case "11"
    str2 = "November"
    Case "12"
    str2 = "December"
    End Select
    strmonth = str2

    MsgBox strmonth


    Hope it helps

    H.
    Just trying to muddle through...

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    How about monthname function? It even returns the name in your language you've set on your comp:
    Code:
    Msgbox monthname(month(strdate ))
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Thumbs up

    Thanks everyone I now can make this function shorter and actually work!
    Matt

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'easier this way.
    Private Sub Command1_Click()
        MsgBox Format(Text1.Text, "mmmm")
    End Sub
    
    Private Sub Form_Load()
        Text1 = "2000/11/19"
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width