Why is this happening? On_load problem.
I have a main form with a button, when the button is clicked, the second form is loaded. The second form should load with text boxes containing certain values, it doesn't.
Then when i click back to the main form and the once again forward(for the second time) the text boxes contain the correct value.
Can anyone help??
The best thing to do is check my later post as i have modified this original post.
Many thanks.
I thnk the eror is to do with this part of the code.
For i = 0 To UBound(feed_data)
j = TotalEnergy Mod feed_data(i, 1)
k = TotalEnergy Mod feed_data(i, 1)
If j > 50 Then
j = feed_data(i, 1) - j
End If
If j < mj Then
mj = j
feed_divisor = feed_data(i, 1)
If k > 50 Then
feed_repetitions = (TotalEnergy / feed_divisor) + 1
Else
feed_repetitions = (TotalEnergy / feed_divisor)
End If
chosen_type = feed_data(i, 0)
End If
Next
[1227 byte] By [
med_82] at [2007-11-19 7:29:02]

# 2 Re: Why is this happening? On_load problem.
1) Does it work right the first time but fail from then on?
No, the other way around. When you click from the first form to the second form, the values are not displayed correctly. Then when you click back to the first form, and then (for the second time and thereafter) back to the second form, the values appear correctly.
2) Can you zip up your code?
I have attached a zipped copy of the code. I have simplified the application to make it easier for you to see the problem.
Run the program, remember it is a smart device application, so will be deployed in an emulator-select 'Pocket PC 2003 Emulator' if you have the choice.
You will need to navigate to the application from your emulator screen, so click Start >
Programs >
File Explorer >
My Documents >
My Device >
Program Files >
Dietician Assistant >
Dietician Assistant.
Click on the 'Calculator' button on the main form.
The second form is displayed.
The text boxes for 'Suggested Feed' and 'Quantity' are incorrect.
Click Back
Click 'Calculator' button
This tome when the second form is displayed, the text box values for 'Suggested Feed' and 'Quantity' are correct.
Please can you help?
med_82 at 2007-11-10 3:18:52 >

# 3 Re: Why is this happening? On_load problem.
Ok, so it appears that it does show some values, just not the correct values? Can you tell us what the correct values should be?, and how the logic is supposed to work? Then maybe we can pin-point the problem.
# 4 Re: Why is this happening? On_load problem.
If you have looked at the zipped file, you will see that when run, the first form appears. When you click on the button in form 1, form 2 should appear and display the correct values in the text boxes.
On the FIRST opening of the second form, all but two of the text boxes display the correct values. The 'suggested feed' ad the 'quantity' text box do not show the correct values, they do however appear with the correct values if you 'click back' to the first form and then 'click forward' to the second form.
med_82 at 2007-11-10 3:20:53 >

# 5 Re: Why is this happening? On_load problem.
Here is the problem... when you show the 2nd form (the first time), it has data in every textbox. Whether it's the right data or not, we have no idea. You have to tell us what the correct data should be, and how its supposed to work. You could have a < where there should be a >, but since we don't know the logic, it looks fine to us.