473,396 Members | 2,106 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,396 software developers and data experts.

Textbox control

I hope someone can help me!! I am fairly new at VB and I have already tried searching for the answer...hope this isn't a repeat.

Question is: I want to disable/enable an array of textboxes, e.g. Text2(i).Text, located in frmexposurepaths within the frame called receptor. What i have so far:

If blah blah Then
frmexposurepaths!Text2(i).Text.Enabled = False
Else
frmexposurepaths!Text2(i).Text.Enabled = True
End If

But obviously this doesn't work. :) Any ideas?

DonnaDarko
Mar 2 '07 #1
8 1360
I hope someone can help me!! I am fairly new at VB and I have already tried searching for the answer...hope this isn't a repeat.

Question is: I want to disable/enable an array of textboxes, e.g. Text2(i).Text, located in frmexposurepaths within the frame called receptor. What i have so far:

If blah blah Then
frmexposurepaths!Text2(i).Text.Enabled = False
Else
frmexposurepaths!Text2(i).Text.Enabled = True
End If

But obviously this doesn't work. :) Any ideas?

DonnaDarko
Hi if you are already in that form then just get rid of the frmexposurepaths
<code>
if blah blah then
text2(i).enable = false
Else
text2(i).enable = true
end if
</code>

if however you need to relate it with another form, then

<code>
if blah blah then
frmexposurepaths.text2(i).enable = false
Else
frmexposurepaths.text2(i).enable = true
end if
</code>
Mar 2 '07 #2
With the changes you suggested, it now picks and chooses elements from 'i' and doesn't disable/enable the entire array?!!

Please advise again and thanks in advance!

If receptor.Option1(1).Value = True Then
Check1(1).Enabled = False
Check1(1).Value = 0
frmexposurepaths.Text2(i).Enabled = False
Else
Check1(1).Enabled = True
Check1(1).Value = 1
frmexposurepaths.Text2(i).Enabled = True
End if
Mar 2 '07 #3
Geoff
17
For it to work over the entire array there is many ways you could do it.

One of the preferd ways would be doing a loop.

Expand|Select|Wrap|Line Numbers
  1. Dim intA as Integer
  2. For intA = 1 to 10
  3.    If receptor.Option1(intA).Value = True Then
  4.       Check1(intA).Enabled = False
  5.       Check1(intA).Value = 0
  6.       frmexposurepaths.Text2(intA).Enabled = False
  7.    Else
  8.       Check1(intA).Enabled = True
  9.       Check1(intA).Value = 1
  10.       frmexposurepaths.Text2(intA).Enabled = True
  11.    End if
  12. Next intA
  13.  
With this you'd have to change the line:
Expand|Select|Wrap|Line Numbers
  1. For intA = 1 to 10
to the place in the array you'd like to modify... at the moment this would go from array item 1 - 10.

Hope it helps,
Geoff.
Mar 2 '07 #4
Hello again!

What was suggested so far, isn't working. It gets lost in the array somewhere, confusing i think the number of elements associated with the Option1(i) button, which goes from 0 to 2, and the Check1(i) array, which goes from 0 to 14.


Here is what I now have, which doesn't work at all:

Dim intA As Integer
For intA = 1 To 14
If receptor.Option1(intA).Value = True Then
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text2(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text4(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text5(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text6(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text7(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text11(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text12(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text13(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text14(intA).Enabled = False
Else
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text2(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text4(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text5(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text6(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text7(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text11(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text12(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text13(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text14(intA).Enabled = True
End If
Next intA

Also, the else part of this statement then permanently turns those pathways on, and they can no longer be deselected for Option1(0).

Please advise!!! and thanks!

DonnaDarko
Mar 5 '07 #5
Hello again!

What was suggested so far, isn't working. It gets lost in the array somewhere, confusing i think the number of elements associated with the Option1(i) button, which goes from 0 to 2, and the Check1(i) array, which goes from 0 to 14.


Here is what I now have, which doesn't work at all:

Dim intA As Integer
For intA = 1 To 14
If receptor.Option1(intA).Value = True Then
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text2(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text4(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text5(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text6(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text7(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text11(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text12(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text13(intA).Enabled = False
Check1(intA).Enabled = False
Check1(intA).Value = 0
frmexposurepaths.Text14(intA).Enabled = False
Else
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text2(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text4(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text5(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text6(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text7(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text11(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text12(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text13(intA).Enabled = True
Check1(intA).Enabled = True
Check1(intA).Value = 1
frmexposurepaths.Text14(intA).Enabled = True
End If
Next intA

Also, the else part of this statement then permanently turns those pathways on, and they can no longer be deselected for Option1(0).

Please advise!!! and thanks!

DonnaDarko
Hi i am not too sure on what you actually want however if you want to enable and disable the control and all of its array then you can do it in a loop

Dim intcount as integer

If receptor.Option1(1).Value = True Then
Check1(1).Enabled = False
Check1(1).Value = 0
For intcount = 0 to frmexposurepaths.Text2.count - 1
frmexposurepaths.Text2(intcount).Enabled = False
Next intcount
Else
Check1(1).Enabled = True
Check1(1).Value = 1
For intcount = 0 to frmexposurepaths.Text2.count - 1
frmexposurepaths.Text2(intcount).Enabled = True
next intcount
End if


hope this helps
Mar 5 '07 #6
Hi,

Okay, next question; what you suggested has solved the problem of controlling the frame containing the textboxes, THANK YOU. But, I still don't have proper control of the option buttons. This is difficult to explain online i guess, but thank you for trying to understand me anyway!! Here goes:

The Option1(i) button is an array that goes from 0 to 2. If Option1(1) is selected, then i want to enable and disable the checkboxes located in the same frame as the option button (as well as the textboxes, which are located on a different form, and which has been solved by the earlier reply). However, switching between e.g. Option1(0) and Option1(1) does not deactivate the associated Check1(i) buttons as shown above. I show a smaller selection below including the changes made for the textboxes.

Dim intcount As Integer
If receptor.Option1(1).Value = True Then
Check1(1).Enabled = False
Check1(1).Value = 0
For intcount = 0 To frmexposurepaths.Text2.Count - 1
frmexposurepaths.Text2(intcount).Enabled = False
Next intcount
Check1(3).Enabled = False
Check1(3).Value = 0
For intcount = 0 To frmexposurepaths.Text4.Count - 1
frmexposurepaths.Text4(intcount).Enabled = False
Next intcount
Else
Check1(1).Enabled = True
Check1(1).Value = 1
For intcount = 0 To frmexposurepaths.Text2.Count - 1
frmexposurepaths.Text2(intcount).Enabled = True
Next intcount
Check1(3).Enabled = True
Check1(3).Value = 1
For intcount = 0 To frmexposurepaths.Text4.Count - 1
frmexposurepaths.Text4(intcount).Enabled = True
Next intcount
End If
___________________________

I already tried creating a loop, using:

Dim intA As Integer
For intA = 0 To 2 'my Option1 button has 3 choices
........

but this didn't work. After all, i need it to recognize and differentiate between the different options. So if Option1(0) is selected, then everything should be enabled, and if Option1(1) is selected, then the specified Checkboxes should be deactivated (along with their textboxes). But this isnt working yet. The other problem is, that, by specifying after the Else, that the Check1(i).Value = 1, i think this permanently turns the checkbox on; which i also dont want.

BTW, do i have to include programming in the OKButton section as well as the Form_load section of the code on this form???

Can you help me again?!! Thanks soooo much!
Mar 5 '07 #7
Hi,

Okay, next question; what you suggested has solved the problem of controlling the frame containing the textboxes, THANK YOU. But, I still don't have proper control of the option buttons. This is difficult to explain online i guess, but thank you for trying to understand me anyway!! Here goes:

The Option1(i) button is an array that goes from 0 to 2. If Option1(1) is selected, then i want to enable and disable the checkboxes located in the same frame as the option button (as well as the textboxes, which are located on a different form, and which has been solved by the earlier reply). However, switching between e.g. Option1(0) and Option1(1) does not deactivate the associated Check1(i) buttons as shown above. I show a smaller selection below including the changes made for the textboxes.

Dim intcount As Integer
If receptor.Option1(1).Value = True Then
Check1(1).Enabled = False
Check1(1).Value = 0
For intcount = 0 To frmexposurepaths.Text2.Count - 1
frmexposurepaths.Text2(intcount).Enabled = False
Next intcount
Check1(3).Enabled = False
Check1(3).Value = 0
For intcount = 0 To frmexposurepaths.Text4.Count - 1
frmexposurepaths.Text4(intcount).Enabled = False
Next intcount
Else
Check1(1).Enabled = True
Check1(1).Value = 1
For intcount = 0 To frmexposurepaths.Text2.Count - 1
frmexposurepaths.Text2(intcount).Enabled = True
Next intcount
Check1(3).Enabled = True
Check1(3).Value = 1
For intcount = 0 To frmexposurepaths.Text4.Count - 1
frmexposurepaths.Text4(intcount).Enabled = True
Next intcount
End If
___________________________

I already tried creating a loop, using:

Dim intA As Integer
For intA = 0 To 2 'my Option1 button has 3 choices
........

but this didn't work. After all, i need it to recognize and differentiate between the different options. So if Option1(0) is selected, then everything should be enabled, and if Option1(1) is selected, then the specified Checkboxes should be deactivated (along with their textboxes). But this isnt working yet. The other problem is, that, by specifying after the Else, that the Check1(i).Value = 1, i think this permanently turns the checkbox on; which i also dont want.

BTW, do i have to include programming in the OKButton section as well as the Form_load section of the code on this form???

Can you help me again?!! Thanks soooo much!
Hi obviously the first thing i noticed was that option(0) has no code to it so you can use a loop from 0 to 1 so it only uses thoes two controls or just fudge it and if the option buttons are an array double click into it and paste what you have done in the Click event. (Index) is the array count so where you have
option(0) use option(index), if you chose check(i).value = 1 will apply a tick in the checkbox this can be got ridden of by check(i).value = 0
Mar 5 '07 #8
Hello!

Problem solved! Thank you so much for the help. Actually, the last problem was that the code was in the wrong place. So i added a Call function for the subroutine associated with the Option1(i) button and deleted the code completely from the Form_load section. You gave me the idea when you mentioned there was no code associated with the Option button. Such a silly mistake!

Thanks!!
Mar 5 '07 #9

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

Similar topics

0
by: Mark Johnson | last post by:
The last reply got sort of cutoff. So here again: So for anyone interested, here's the simple regexp patterns for the substitutions required. The textbox control is being 'zoomed' in a popup...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
0
by: Dot net work | last post by:
Hi, Make up a very simple project as follows: 1 aspx form 3 web user controls (referred to as A, B, and C) "A" web user control: Put 1 textbox and 1 button on this web user control. (You...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
4
by: Samy | last post by:
Hi There, I have a user control with a textbox and a button which when clicked opens a calendar control(calendar.aspx page). When I select a date from the calendar control, the date is supposed to...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
6
by: RP | last post by:
I want to clear all the Text Boxes on the Form. Is there any short method to avoid clearing them one by one.
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
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,...

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.