Look at the case of VFP: analog VB control array Operation Label control

Source: Internet
Author: User

VB has a control array, use it to set the properties of the control, the most direct function of this thing is to simplify the code. Today we simulate the VB control array in VFP, operate one of the most basic controls in VFP: Label control. In VFP Basic Tutorial-Label control (label) in the article on the control of the properties and uses have been described in more detail, there is nothing to say about it.

This example is designed in this article: in the form activation (Activate event), a similar VB control array is used to set properties for each label in a circular statement, as shown in Figure 1, as shown in the Click event of a command button, by clicking the value of the 5 label's Caption property in turn , figure 2 below;

Figure 1

Figure 2

The production steps are as follows:

A new form, set its AutoCenter property value to. T, and save it as "form 1.scx".

Add 5 Label control Label1~label5 to the form, and set their Caption property value to "edit", "process", "enter", "door", "net".

Add a command button Command1 to the form and set its Caption property value to display characters.

Four, adjust the position of each control appropriately, the following figure:

V. Add event code:

1, the form of the Activate event code:

Public Top,n The local
fs,fb,fc
n=1
top=thisform.label1.top for I=1 to
5
    t= ' label ' +str (i,1) + ". Top"
    fs= "label" +STR (i,1) + ". FontSize"
    fb= "label" +STR (i,1) + ". FontBold"
    fc= "label" +STR (i,1) + ". ForeColor"
    thisform.&t=-50 && in turn, set the top property value of 5 tags to 50, which is actually hiding them
    thisform.&fs=12 && In turn, set the value of the FontSize property of the 5 labels to
    thisform.&fb=.t. && Set the FontBold property value of 5 labels to. T.
    Thisform.&fc=rgb (255,0,0) && in turn, set the value of the ForeColor property of 5 labels to RGB (255,0,0)
endfor

2, the command button Command1 Click event Code:

t= "Label" +STR (n,1) + ". Top"
if thisform.&t<=top-50
  thisform.&t=top
  n=n+1
  if n=6
     n=1
     this.enabled=.f.
     MessageBox ("The characters are all displayed!")
     return
  endif
endif

Six, run "form 1.scx".

This example code is debugged in the win2003+vfp6.0 environment.

See the full set of "rookie also learn VFP" tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.