Problems Calling A Function
-
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 FunctionIf 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 typegetCurrentDayOfWeek(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: -
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 FunctionIf 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 typegetCurrentDayOfWeek(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: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
-
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
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:
-
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:
-
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 FunctionIf 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 typegetCurrentDayOfWeek(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: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
-
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
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.
-
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.
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
-
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
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
-
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
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
-
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
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
-
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 FunctionIf 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 typegetCurrentDayOfWeek(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: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
-
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
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