Home > Software engineering >  Hide the form controls
Hide the form controls

Time:10-02

'in a form before enter a number between 2 ~ 20, the name is InputNumber, according to the decision after a form in the textbox control the number of rows, had previously put up 20 row 2 column textbox, 16, if the input is hidden after four lines, namely textbox17 ~ (20 ~ 40.
But has written the following code, but can't achieve the function of the hidden, deliver a great god, see how to change!


Public Sub InputCoord ()
'based on a dialog box enter the number of groups InputNumber, painting form, hidden extra form
Dim As Integer I
Dim As Integer k
K=20 - InputNumber
For I=0 To k
If I & lt; K Then
The Set m=20 - I
Set n=40 -i
TextBoxm. Visible=False
TextBoxn. Visible=False
Labelm. Visible=False
End the If
Next I

'adjust the entire window length
InputNumber3. Height=435-18 * k
'the position adjustment of the "back" button
BackButton3. Top=378-18 * k
'adjustment "empty" button location
ClearButton3. Top=342-18 * k

'adjustment to empty button positionComButton3. Top=306-18 * k
End Sub
'click back button
Private Sub BackButton3_Click ()
InputNumber3. Hide
IfYes2. Show
End Sub

Click on the delete button, 'ClearYes4 dialog asking whether empty
Private Sub ClearButton3_Click ()
ClearYes4. Show
End Sub

'click confirm button
Private Sub ComButton3_Click ()
'did not fill out the form, have encountered an error
For I=1 To InputNumber
If (Me. Controls ((" textbox "& amp; I))="" Or Me. Controls (" textbox" & amp; 20 + I))="") Then
MsgBox "No empty entries allowed!"
End the If
Next I
'pop-up warm prompt CommandYes4 dialog box, confirm whether the data is wrong
CommandYes4. Show
End Sub

CodePudding user response:

For I=0 To k
If I & lt; K Then
Set m =20 -i
Set n=40 -i
TextBoxm .
Visible=FalseTextBoxn. Visible=False
Labelm. Visible=False

The code above is not an error? Regardless of the function whether is in order to implement in a textbox, if he wants to hide, generally using the controls on the form for each cycle, if found horse
Match items can be hidden, if it's a cycle by traversing the textbox controls to implement,

CodePudding user response:

God the same code

CodePudding user response:

Alas, even when the bottom of the farmers, also have the basic program of intuition, refueling ah..

CodePudding user response:

This very simple ah, how?

CodePudding user response:




reference 1st floor ChoasRules response:
For I=0 To k
If I & lt; K Then
Set m =20 -i
Set n=40 -i
TextBoxm .
Visible=FalseTextBoxn. Visible=False
Labelm. Visible=False

The code above is not an error? Regardless of the function whether is in order to implement in a textbox, if he wants to hide, generally using the controls on the form for each cycle, if found horse
Match items can be hidden, if it's a cycle by traverse the textbox control,



Thank you very much! But it is not an error==
It still didn't understand, that how to change?
Just started VBA class, is not white, can issue a bit childish, hope the great god forgive me!

CodePudding user response:

refer to the second floor u011266608 response:
god as the code


Well I also feel everyone seems the problem must be an idiot but just started or the cheek to ask what I want to how to realize the function of it?

CodePudding user response:

reference bcrun reply: 3/f
well, even when the bottom of the farmers, also have the basic program of intuition, refueling ah the building Lord,


Just began to learn, will refuel!
But could you tell me how to change this?==

CodePudding user response:

It doesn't matter, after skilled basically don't do that...

Give a part of the hidden under the code, you consult:
 Sub test () 
' ' ' '...
K=InputNumber 'input the number of rows
Dim bTr As Boolean
For I=1 To 20 ', a total of 20 lines
BTr=I & lt;=k
Me. Controls (" textbox "& amp; CStr (I)). The Visible=bTr
Me. Controls (" textbox "& amp; CStr (I) + 20). The Visible=bTr
Next I
"'...
End Sub




M=10, cannot use Textboxm representative textbox10...

CodePudding user response:

refer to 6th floor candice_0922 response:
Quote: refer to the second floor u011266608 response:

God the same code


Well I also feel everyone seems the problem must be an idiot but just started or the cheek to ask what I want to how to realize the function of it?


No error code, the same code said to god,,,

CodePudding user response:

I modified the code, you see I am so tired because of the give me
Your code is
Public Sub InputCoord ()
'based on a dialog box enter the number of groups InputNumber, painting form, hidden extra form
Dim As Integer I
Dim As Integer k
K=20 - InputNumber 'InputNumber is a textbox, here? Is words to modify InputNumber. Text (note: get a textual)
For I=0 To k 'because you didn't get the value of k in the previous part, VB defaults To 0
If I & lt; K Then 'here you thought wrong, because in the loop, I you are less than k, oh, the last is a=
Set m=20 - "I'm here, VB is not so for variable assignment, should be m=20 -i
Set n=40 -i
TextBoxm. Visible=False "TextBoxm. There is no error, should be just a TextBoxm button, estimated that you want to achieve the goal of textbox1 ~ N, this is wrong, the control can't call, even if you want to get textbox1, should also be written as" text "& amp; I this is the place where wrong
TextBoxn. Visible=False
Labelm. Visible=False
End the If
Next I

'adjust the entire window length
InputNumber3. Height=435-18 * k 'InputNumber3: are you sure you really have an InputNumber3 this control?
'the position adjustment of the "back" button
BackButton3. Top=378-18 * k 'BackButton3: are you sure you really have this control? Control's name, to look at the name of the control, rather than controls caption
'adjustment "empty" button location
ClearButton3. Top=342-18 * k

'adjustment to empty button positionComButton3. Top=306-18 * k
End Sub
'click back button
Private Sub BackButton3_Click ()
InputNumber3. Hide
IfYes2. Show
End Sub

Click on the delete button, 'ClearYes4 dialog asking whether empty
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • VBA
  • Related