473,463 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please I need Help Urgently on this

5
I have these codes that are supposed to load control arrays (days of week), there is only one textbox visible at design time, but I want to use control array to initialize the other six textboxes in order to display (Monday-Sunday) according to local system settings. But when I compile it only shows the error message and when i click OK, it then shows the form with the number "70" on it.
Please could anyone help me figure out what might be wrong and the solution? Thanks in advance


visual basic code:--------------------------------------------------------------------------------Private Sub Form_Load()
Call GetWeekDay
Call Update_Controls
End Sub


Private Function GetWeekDay()
On Error GoTo Error_Handle
Weekday(0) = WeekdayName(vbUseSystemDayOfWeek)
Weekday(1) = WeekdayName(vbTuesday)
Weekday(2) = WeekdayName(vbWednesday)
Weekday(3) = WeekdayName(vbThursday)
Weekday(4) = WeekdayName(vbFriday)
Weekday(5) = WeekdayName(vbSaturday)
Weekday(6) = WeekdayName(vbSunday)

Dim i As Integer

For i = 0 To 5
Load txtwkdayname(txtwkdayname.UBound + 1)
txtwkdayname(txtwkdayname.UBound).Top = (txtwkdayname(i).Top + txtwkdayname(i).Height) + 8
txtwkdayname(txtwkdayname.UBound).Visible = True
Next i
Error_Handle:
MsgBox "Please Check Your Codes"

End Function

Private Sub Update_Controls()

Dim i As Integer

For i = 0 To txtwkdayname.UBound
txtwkdayname(i).Text = Weekday(i) & i
Next i

End Sub--------------------------------------------------------------------------------


When I change the Error message from "Error handler to "On Error Reume Next" I got a diferent result:
Six extra txtboxes were added as I wanted, but then there were numbers from 7(the default textbox), 1,2...6. I wanted them to display, from Monday-Sunday in the local system form.
What should I do to correct this?

Also How Can I claculate and display lunch hours(in and Out)?
Nov 26 '06 #1
8 1568
willakawill
1,646 1GB
I have these codes that are supposed to load control arrays (days of week), there is only one textbox visible at design time, but I want to use control array to initialize the other six textboxes in order to display (Monday-Sunday) according to local system settings. But when I compile it only shows the error message and when i click OK, it then shows the form with the number "70" on it.
Please could anyone help me figure out what might be wrong and the solution? Thanks in advance


visual basic code:--------------------------------------------------------------------------------Private Sub Form_Load()
Call GetWeekDay
Call Update_Controls
End Sub


Private Function GetWeekDay()
On Error GoTo Error_Handle
Weekday(0) = WeekdayName(vbUseSystemDayOfWeek)
Weekday(1) = WeekdayName(vbTuesday)
Weekday(2) = WeekdayName(vbWednesday)
Weekday(3) = WeekdayName(vbThursday)
Weekday(4) = WeekdayName(vbFriday)
Weekday(5) = WeekdayName(vbSaturday)
Weekday(6) = WeekdayName(vbSunday)

Dim i As Integer

For i = 0 To 5
Load txtwkdayname(txtwkdayname.UBound + 1)
txtwkdayname(txtwkdayname.UBound).Top = (txtwkdayname(i).Top + txtwkdayname(i).Height) + 8
txtwkdayname(txtwkdayname.UBound).Visible = True
Next i
Error_Handle:
MsgBox "Please Check Your Codes"

End Function

Private Sub Update_Controls()

Dim i As Integer

For i = 0 To txtwkdayname.UBound
txtwkdayname(i).Text = Weekday(i) & i
Next i

End Sub--------------------------------------------------------------------------------


When I change the Error message from "Error handler to "On Error Reume Next" I got a diferent result:
Six extra txtboxes were added as I wanted, but then there were numbers from 7(the default textbox), 1,2...6. I wanted them to display, from Monday-Sunday in the local system form.
What should I do to correct this?

Also How Can I claculate and display lunch hours(in and Out)?
Hi looks like you have some global variables defined somewhere not in this code snippet. Could you also post these declarations?
Thanks
Nov 27 '06 #2
Killer42
8,435 Expert 8TB
I think you have failed to Exit Sub before your Error_Handle label.
Nov 27 '06 #3
ukwa
5
I think you have failed to Exit Sub before your Error_Handle label.
If I Exit SUB, like you said I get this message: "Compiler Error:label "On Error GoTo Error_Handle" not defined
Nov 27 '06 #4
Killer42
8,435 Expert 8TB
If I Exit SUB, like you said I get this message: "Compiler Error:label "On Error GoTo Error_Handle" not defined
I'm not sure we're talking about the same thing (plus, I got Sub and Function mixed up). Try this
Expand|Select|Wrap|Line Numbers
  1. Private Function GetWeekDay()
  2. On Error GoTo Error_Handle
  3. Weekday(0) = WeekdayName(vbUseSystemDayOfWeek)
  4. Weekday(1) = WeekdayName(vbTuesday)
  5. Weekday(2) = WeekdayName(vbWednesday)
  6. Weekday(3) = WeekdayName(vbThursday)
  7. Weekday(4) = WeekdayName(vbFriday)
  8. Weekday(5) = WeekdayName(vbSaturday)
  9. Weekday(6) = WeekdayName(vbSunday)
  10.  
  11. Dim i As Integer
  12.  
  13. For i = 0 To 5
  14.   Load txtwkdayname(txtwkdayname.UBound + 1)
  15.   txtwkdayname(txtwkdayname.UBound).Top = (txtwkdayname(i).Top + txtwkdayname(i).Height) + 8
  16.   txtwkdayname(txtwkdayname.UBound).Visible = True
  17. Next i
  18. Exit Function
  19. Error_Handle:
  20. MsgBox "Please Check Your Codes"
  21.  
  22. End Function
Oh, and a question (not terribly important, I'm just curious). Since this returns no value, is there any particular reason why it's a function rather than a Sub?
Nov 27 '06 #5
ukwa
5
Hi looks like you have some global variables defined somewhere not in this code snippet. Could you also post these declarations?
Thanks
Hi, thanks but I didnt declare any variable except the control variable(i) for looping, well, even as I added Weekday as variable I get these results(7,1,2,3,4,5,6). I dont know why its giving numbers instead of weekdays in local language. Thats the problem i am having at the moment. Here is how its been improved on now:

Option Explicit
Private Sub Form_Load()
Call GetWeekDay
Call Update_Controls
End Sub



Private Function GetWeekDay()
On Error Resume Next................................'I had to change this in order to
'make it run without error
Dim Weekday(6) As Date...... 'Gives same reult whether or not present'
Weekday(0) = WeekdayName(vbUseSystemDayOfWeek)
Weekday(1) = WeekdayName(vbTuesday)
Weekday(2) = WeekdayName(vbWednesday)
Weekday(3) = WeekdayName(vbThursday)
Weekday(4) = WeekdayName(vbFriday)
Weekday(5) = WeekdayName(vbSaturday)
Weekday(6) = WeekdayName(vbSunday)

Dim i As Integer

For i = 0 To 5
Load txtwkdayname(txtwkdayname.UBound + 1)
txtwkdayname(txtwkdayname.UBound).Top = (txtwkdayname(i).Top + txtwkdayname(i).Height) + 8................................................. .......................'needed to avoid cluttering
txtwkdayname(txtwkdayname.UBound).Visible = True
Next i


End Function

Private Sub Update_Controls()

Dim i As Integer

For i = 0 To txtwkdayname.UBound
txtwkdayname(i).Text = Weekday(i)
Next i

End Sub
Nov 27 '06 #6
Killer42
8,435 Expert 8TB
See my message just before willakawill's, about Exit Function.

Also, it seems as though you might need to define an array somewhere called Weekday(0 to 7). Either at the form level, or in a module as Public.
Nov 27 '06 #7
Killer42
8,435 Expert 8TB
See my message just before willakawill's, about Exit Function.

Also, it seems as though you might need to define an array somewhere called Weekday(0 to 7). Either at the form level, or in a module as Public.
Sorry, correction. Your array Weekday() is defined as Date - make it String.
Nov 27 '06 #8
ukwa
5
Sorry, correction. Your array Weekday() is defined as Date - make it String.
Thanks I have resolved the problem
Nov 27 '06 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Kelly G. | last post by:
I need to register a Vb DLL under restricted acess privilages please provide me a solution. Here is the complete issue: I building a MSI using Vs.net ,One of the Dll's is Vb Component ( A shim...
0
by: Calvin KD | last post by:
Hi everyone, I need help urgently. I have a C#.Net app which uses cookies for state management (since we've gone away from Session for fear of webfarm and we haven't found the need for SQL Server...
0
by: Calvin KD | last post by:
Hi everyone, I need help urgently. I have a C#.Net app which uses cookies for state management. Everything has been going fine until recently we've expanded the app and a few more screens were...
5
by: uanmi | last post by:
There is a patch to upgrade UAB2 to dotnet 2 on gotdotnet But, as normal, there are no instructions on what to do to patch the Microsoft UAB 2 install. Can Microsoft please upgrade their UAB2...
4
by: Flamingo | last post by:
Hi folks, I want a webpage, there would be a input textfield, and a "sumbit" button there, if you press the submit button, the contents you input to the textfield would be send to your...
4
by: Joonshik Kim | last post by:
I was trying to define 3d array with pointer to pointer. I wrote like following. int ***d; nx = 3; ny = 5; nz = 4; d = (int ***)malloc((int) nx*sizeof(int **)); *d = (int **)malloc((int)...
1
by: dillipb | last post by:
Please Reply Urgently In the given string '<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/${5}\"></param><param name=\"wmode\"...
0
by: efix | last post by:
hey there i need help urgently.. neone hu cud help me?? U c i m tryin t figure out how to program a vb .exe to login into a internet account inreal time. i m playin an online game....
2
by: rkarthik | last post by:
Hello vectors, I am a beginner in vb.net programming and a student. As my final year project I wish to develop a compression tool.Is there any way to impleiment Huffman's compression algorithm in...
16
by: techystud | last post by:
Hi, I am doing a Left Join between two views wherein the column used in the ON condition has empty string rows in the first view. while running the query the application flashes, shows #ERROR...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.