473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

User Function with input variable as

In the example below I have chosen to define the input variable in a text box called Text_year. The function is run from a for with a Toggle Button. The text box in the same form. My purpose in to invite user to input a year in the text box to obtain the number of days in that year.

The error message given reads:
Control can't be edited ; it's bound to the expression 'DaysInYear([Text_year])

The function:
Expand|Select|Wrap|Line Numbers
  1. Public Function DaysInYear (ByVal Year As Integer) As Integer
  2.  
  3.     Dim LeapDays As Integer
  4.     LeapDays =0
  5.     If Year Mod 4 = 0 Then LeapDays = 1
  6.     DaysInYear = 365 + LeapDays
  7. End Function
Any help will be greatly appreciated.
Nov 25 '09 #1
7 2696
ajalwaysus
266 Expert 100+
Are you allowing them to input the year in one field and showing the number of days in another, or are you trying to change the value in the same text box that they just entered the year in?

This may be your problem, if that is the case. I don't think you can overwrite a value while that value is being used to calculate another value.

I could be way off, but let us know.

-AJ
Nov 25 '09 #2
Many thanks to ajalwaysus.
I have a GetDaysInYear function linked to a second text box to extract the number of days in the year. The error message remains:
The error message given reads:
Control can't be edited ; it's bound to the expression 'DaysInYear([Text_year])
Nov 25 '09 #3
ajalwaysus
266 Expert 100+
Where have you set DaysInYear([Text_year]) in your text box. Did you put it under Control Source?

Also, whether or not this is how you do it now, try to make sure it appears as =DaysInYear([Text_year]) in the control source.

-AJ
Nov 25 '09 #4
NeoPa
32,556 Expert Mod 16PB
Peter, this sounds like you're not paying attention to what you're saying.

Is there a GetDaysInYear() function? Or is it simply DaysInYear() as referred to elsewhere.

Is the operator trying to enter data into the TextBox which has the formula in it (As both AJ and I seem to think)? or are they really entering into one which is unbound as you indicate?

I have to say that the error message seems to contradict what you are saying. Please check your details and reply carefully.
Nov 25 '09 #5
Thank you for the responses. I have made some changes with no results.
Expand|Select|Wrap|Line Numbers
  1. Dim TotalDays as Integer
  2.  
  3. Public Function DaysInYear (ByVal Year As Integer) As Integer 
  4.  
  5.     Dim LeapDays As Integer 
  6.     LeapDays =0 
  7.     If Year Mod 4 = 0 Then LeapDays = 1 
  8.     TotalDays = 365 + LeapDays 
  9. End Function 
  10.  
  11. Public Function GetDaysInYear () 
  12.       GetDaysInYear=    TotalDays
  13. End Function
The control source for the button: DaysInYear([text_year])

The text field [text_year] is left blank. I want to be able to enter values once the form is opened.

In the control source of the second text box: GetReportTotal()
Nov 25 '09 #6
missinglinq
3,532 Expert 2GB
Despite NeoPa's post you continue to apparently really have no idea what it is you're trying to say! You have, once gain, thrown in a heretofore unmentioned function, GetReportTotal(), with no explanation except that it is the Control Source for the "second" textbox. One would suppose, from your previous posts, that the second textbox was the one you wanted to populate with the number of days in the year entered in Text_Year control. If so, how can it have another function as its Control Source?

You are simply going to have to give a better explanation of your scenario here, if you want us to help!

Linq ;0)>
Nov 25 '09 #7
ajalwaysus
266 Expert 100+
Ok, like Linq said, we still don't know what you are doing. But I can tell you what to do to get the results you are looking for, what you need to do:
1. Assume you have a text box named txtYear
2. Create another text box and go to its properties and put "=DaysInYear([txtYear])" in the control source field. (no double quotes!)
3. Keep this code with the tweak I put in:
Expand|Select|Wrap|Line Numbers
  1. Public Function DaysInYear (ByVal Year As Integer) As Integer
  2.  
  3. Dim LeapDays As Integer
  4. LeapDays =0
  5. If Year Mod 4 = 0 Then LeapDays = 1
  6. DaysInYear = 365 + LeapDays
  7. End Function 
4. No need for the GetDaysInYear function or any buttons.

What should happen now is that immediately after the user enters a year, the other text box will automatically display the number of days for you.

Try this,
-AJ
Nov 25 '09 #8

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

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
9
by: CW | last post by:
I wrote an HTML based chat application. The front end is built entirely on HTML + javascript. Essentially, I have a hidden frame that's refreshed frequently and any new messages are displayed in...
10
by: jeff regoord | last post by:
A user inputs a float value. The scanf() function gets the value. However, I need to create an error handler with an if else statement saying invalid input if the input is not a number. Does...
10
by: sqlboy2000 | last post by:
Hello all, I have something very simple going on here and I'm scratching my head as to what the problem is. There are 4 items in my project, 2 webforms, a user control, and a module: ...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
4
by: Mohammed_M | last post by:
Hi, I'm v.new to Python, so please don't be too harsh :) I get a NameError with the code below - All I want to do is store some input taken from the user in a variable called name, & then print...
30
by: Yorian | last post by:
Hey, Although I've been using classes and object for quite a while now I've never actually programmed proper OO code yet. It ofcourse depends on what you call proper OO code. I have been...
4
by: jay123swe | last post by:
Hi. It's been a while since I was here last time and I've learned some things I hope. However I have to do some void functions that return other void functions. My problem isn't really how to do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.