Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problems Calling A Function

Problems Calling A Function

Scheduled Pinned Locked Moved Visual Basic
debugginghelptutorialquestion
12 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N nlarson11

    is your first call Sunday? where is CASE 0?

    'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

    P Offline
    P Offline
    Phantom715
    wrote on last edited by
    #3

    There is no Case 0. It should always be sending a DayOfWeek. There is a similar Case statement for each day of the week. Or maybe I didn't understand your question. :laugh:

    N 1 Reply Last reply
    0
    • P Phantom715

      There is no Case 0. It should always be sending a DayOfWeek. There is a similar Case statement for each day of the week. Or maybe I didn't understand your question. :laugh:

      N Offline
      N Offline
      nlarson11
      wrote on last edited by
      #4

      oooooooops misread your code.

      'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

      1 Reply Last reply
      0
      • P Phantom715

        Hello everyone! Really confused by this problem. Usually I can search and find an answer, but I'm not even sure how to search for it. I have a function (obviously includes all days of the week, but shortened for shortness' sake):

        Function getlabel(ByVal day As DayOfWeek, ByVal calendarRow As Integer) As System.Windows.Forms.Label
        Select Case day 'Get a label name
        Case DayOfWeek.Sunday
        Select Case calendarRow
        Case 1
        Return su1
        Case 2
        Return su2
        Case 3
        Return su3
        Case 4
        Return su4
        Case 5
        Return su5
        Case 6
        Return su6
        End Select
        End Select
        End Function

        If I call it by: Dim CurrentDayNum As Integer = CInt(getlabel(getCurrentDayOfWeek(dayShortName), CInt(ClickedLabel.Name.Substring(0, 4))).Name) It returns nothing. If I call it by a direct "DayOfWeek": Dim CurrentDayNum As Integer = CInt(getlabel(DayOfWeek.Thursday, CInt(ClickedLabel.Name.Substring(0, 4))).Name) It works fine, and returns the proper label. When I type getCurrentDayOfWeek(dayShortName) into the debugger, it gives me: Thursday getCurrentDayOfWeek is a Function As DayOfWeek I hope that wasn't too confusing, I can be that way. Anybody have any suggestions? :confused:

        C Offline
        C Offline
        Caio Kinzel Filho
        wrote on last edited by
        #5

        Is your return type of getCurrentDayOfWeek(), DayOfWeek? In which point did you try getCurrentDayOfWeek(dayShortName) in the debugger?

        Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

        P 1 Reply Last reply
        0
        • C Caio Kinzel Filho

          Is your return type of getCurrentDayOfWeek(), DayOfWeek? In which point did you try getCurrentDayOfWeek(dayShortName) in the debugger?

          Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

          P Offline
          P Offline
          Phantom715
          wrote on last edited by
          #6

          Caio Kinzel Filho wrote:

          Is your return type of getCurrentDayOfWeek(), DayOfWeek?

          Yes it is.

          Caio Kinzel Filho wrote:

          In which point did you try getCurrentDayOfWeek(dayShortName) in the debugger?

          As soon as dayShortName was set, right before the problem function call.

          C 1 Reply Last reply
          0
          • P Phantom715

            Caio Kinzel Filho wrote:

            Is your return type of getCurrentDayOfWeek(), DayOfWeek?

            Yes it is.

            Caio Kinzel Filho wrote:

            In which point did you try getCurrentDayOfWeek(dayShortName) in the debugger?

            As soon as dayShortName was set, right before the problem function call.

            C Offline
            C Offline
            Caio Kinzel Filho
            wrote on last edited by
            #7

            can you post your getCurrentDayOfWeek function? I tryied here and works fine...

            Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

            P 1 Reply Last reply
            0
            • C Caio Kinzel Filho

              can you post your getCurrentDayOfWeek function? I tryied here and works fine...

              Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

              P Offline
              P Offline
              Phantom715
              wrote on last edited by
              #8

              No problem.

              Private Function getCurrentDayOfWeek(ByVal dayName As String) As DayOfWeek
                  Select Case dayName
                      Case "su"
                          getCurrentDayOfWeek = DayOfWeek.Sunday
                      Case "mo"
                          getCurrentDayOfWeek = DayOfWeek.Monday
                      Case "tu"
                          getCurrentDayOfWeek = DayOfWeek.Tuesday
                      Case "we"
                          getCurrentDayOfWeek = DayOfWeek.Wednesday
                      Case "th"
                          getCurrentDayOfWeek = DayOfWeek.Thursday
                      Case "fr"
                          getCurrentDayOfWeek = DayOfWeek.Friday
                      Case "sa"
                          getCurrentDayOfWeek = DayOfWeek.Saturday
                  End Select
                  Return getCurrentDayOfWeek
              End Function
              
              C 2 Replies Last reply
              0
              • P Phantom715

                No problem.

                Private Function getCurrentDayOfWeek(ByVal dayName As String) As DayOfWeek
                    Select Case dayName
                        Case "su"
                            getCurrentDayOfWeek = DayOfWeek.Sunday
                        Case "mo"
                            getCurrentDayOfWeek = DayOfWeek.Monday
                        Case "tu"
                            getCurrentDayOfWeek = DayOfWeek.Tuesday
                        Case "we"
                            getCurrentDayOfWeek = DayOfWeek.Wednesday
                        Case "th"
                            getCurrentDayOfWeek = DayOfWeek.Thursday
                        Case "fr"
                            getCurrentDayOfWeek = DayOfWeek.Friday
                        Case "sa"
                            getCurrentDayOfWeek = DayOfWeek.Saturday
                    End Select
                    Return getCurrentDayOfWeek
                End Function
                
                C Offline
                C Offline
                Caio Kinzel Filho
                wrote on last edited by
                #9

                I did this:

                MsgBox(getlabel(DayOfWeek.Sunday, 1))
                MsgBox(getlabel(getCurrentDayOfWeek("su"), 1))
                

                with your function and (for shortness..):

                    Function getlabel(ByVal day As DayOfWeek, ByVal calendarRow As Integer) As String
                        Select Case day  'Get a label name
                            Case DayOfWeek.Sunday
                                Select Case calendarRow
                                    Case 1
                                        Return "Sunday"
                                End Select
                            Case DayOfWeek.Monday
                                Select Case calendarRow
                                    Case 1
                                        Return "Monday"
                                End Select
                            Case DayOfWeek.Tuesday
                                Select Case calendarRow
                                    Case 1
                                        Return "Tuesday"
                                End Select
                        End Select
                    End Function
                

                And it works...other than that...i think you will have to post your entire code...

                Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

                1 Reply Last reply
                0
                • P Phantom715

                  No problem.

                  Private Function getCurrentDayOfWeek(ByVal dayName As String) As DayOfWeek
                      Select Case dayName
                          Case "su"
                              getCurrentDayOfWeek = DayOfWeek.Sunday
                          Case "mo"
                              getCurrentDayOfWeek = DayOfWeek.Monday
                          Case "tu"
                              getCurrentDayOfWeek = DayOfWeek.Tuesday
                          Case "we"
                              getCurrentDayOfWeek = DayOfWeek.Wednesday
                          Case "th"
                              getCurrentDayOfWeek = DayOfWeek.Thursday
                          Case "fr"
                              getCurrentDayOfWeek = DayOfWeek.Friday
                          Case "sa"
                              getCurrentDayOfWeek = DayOfWeek.Saturday
                      End Select
                      Return getCurrentDayOfWeek
                  End Function
                  
                  C Offline
                  C Offline
                  Caio Kinzel Filho
                  wrote on last edited by
                  #10

                  There is no way the CInt(ClickedLabel.Name.Substring(0, 4))).Name could have changed between your calls, and have no valid data in your call using getCurrentDayOkWeek ??

                  Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

                  1 Reply Last reply
                  0
                  • P Phantom715

                    Hello everyone! Really confused by this problem. Usually I can search and find an answer, but I'm not even sure how to search for it. I have a function (obviously includes all days of the week, but shortened for shortness' sake):

                    Function getlabel(ByVal day As DayOfWeek, ByVal calendarRow As Integer) As System.Windows.Forms.Label
                    Select Case day 'Get a label name
                    Case DayOfWeek.Sunday
                    Select Case calendarRow
                    Case 1
                    Return su1
                    Case 2
                    Return su2
                    Case 3
                    Return su3
                    Case 4
                    Return su4
                    Case 5
                    Return su5
                    Case 6
                    Return su6
                    End Select
                    End Select
                    End Function

                    If I call it by: Dim CurrentDayNum As Integer = CInt(getlabel(getCurrentDayOfWeek(dayShortName), CInt(ClickedLabel.Name.Substring(0, 4))).Name) It returns nothing. If I call it by a direct "DayOfWeek": Dim CurrentDayNum As Integer = CInt(getlabel(DayOfWeek.Thursday, CInt(ClickedLabel.Name.Substring(0, 4))).Name) It works fine, and returns the proper label. When I type getCurrentDayOfWeek(dayShortName) into the debugger, it gives me: Thursday getCurrentDayOfWeek is a Function As DayOfWeek I hope that wasn't too confusing, I can be that way. Anybody have any suggestions? :confused:

                    P Offline
                    P Offline
                    Phantom715
                    wrote on last edited by
                    #11

                    I am having difficulty following what people are asking me - I'm new to this, sorry. I have included the entire project at: http://www.ulc119.com/assignmentsheet.zip[^] Any help would be wonderful. Thanks! :-D

                    C 1 Reply Last reply
                    0
                    • P Phantom715

                      I am having difficulty following what people are asking me - I'm new to this, sorry. I have included the entire project at: http://www.ulc119.com/assignmentsheet.zip[^] Any help would be wonderful. Thanks! :-D

                      C Offline
                      C Offline
                      Caio Kinzel Filho
                      wrote on last edited by
                      #12

                      The link doesn't work for me...send it to my email and I will take a look...caiokf@gmail.com Regards

                      Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups