Home > Computer Tutorials > Computer Knowledge > How to write the code to add data to the form in VFP form?

How to write the code to add data to the form in VFP form?

王林
Release: 2024-01-17 12:21:05
forward
1505 people have browsed it

How to write the code to add data to the form in VFP form?

What is the code for how to add data to a table using a form in VFP

Right-click in the form and select "Data Environment..." to select the table you want.

Then enter the following code in the "Add" button:

SELECT situation table

IF ALLTRIM(THISFORM.text1.VALUE)=''

=MESSAGEBOX ('Please enter your name and other information', 48, 'Message prompt')

RETURN

ENDIF

IF MESSAGEBOX ('Please check carefully to ensure that the entered information is complete and accurate! ' CHR(13) CHR(13) 'Are the above information correct?', 48 4, 'Information prompt') =6

APPEND BLANK

REPLACE Name WITH THISFORM.text1.VALUE, Gender WITH THISFORM.text2.VALUE

REPLACE home address WITH THISFORM.text3.VALUE, date of birth WITH THISFORM.text4.VALUE

REPLACE mobile phone WITH THISFORM.text5.VALUE,QQ WITH THISFORM.text6.VALUE

REPLACE ZIP CODE WITH THISFORM.text7.VALUE,E_mail WITH THISFORM.text8.VALUE

REPLACE Zodiac WITH THISFORM.text9.VALUE, Nationality WITH THISFORM.text10.VALUE

REPLACE NOTE WITH THISFORM.text11.VALUE

STORE '' TO THISFORM.text1.VALUE,THISFORM.text2.VALUE,THISFORM.text3.VALUE

STORE '' TO THISFORM.text4.VALUE,THISFORM.text5.VALUE,THISFORM.text6.VALUE

STORE '' TO THISFORM.text7.VALUE,THISFORM.text8.VALUE,THISFORM.text9.VALUE

STORE '' TO THISFORM.text10.VALUE,THISFORM.text11.VALUE

ENDIF

How to add text boxes in VFP form design. What about entering content in the list box?

Please express yourself clearly when asking questions, preferably with pictures,

1. List box, both additem and addlistitem methods can add data to the list box. The additem method can add records by index number, while the addlistitem method adds records by ID number. Use these two methods to add data. The ROWSOURCETYPE attribute value must be 0 or 1.

control.additem(cItem [,nIndex] [,nColumn]) Among them, cItem is the content of the data item to be added, and nIndex is the index number. If a valid nIndex value is specified, the cItem will be placed at the correct position in the control; if the specified nIndex already exists, the data item will be inserted at this position, and all other data items after this data item will be in the combo box or list box control. Move down one position in the list area. nColumn will specify the column to which the data item is to be added. The default value is 1.

The syntax of the addlistiem method is as follows

control.addlistiem(cItem [,nItemID] [,nColumn])

Among them, cItem and nColumn are the content of the data item to be added and the column to be added. nItemID is the unique ID number of the data item to be added. If the specified nItemID already exists, use cItem to overwrite the content of the current ID data item.

2. Text box

thisform.text1.value="Hello"

Add the above using commands, or you can add it directly

You can set the data type of the text box,

thisform.text1.value=""&Set to character type

thisform.text1.value=0 & set to numeric type

thisform.text1.value={} & set to date type

About VFP data import issues

DECLARE INTEGER ShellExecute IN shell32.DLL INTEGER HWND,STRING,STRING lpszFile, STRING, STRING, INTEGER

eole=CREATEOBJECT('Excel.application')

eole.Workbooks.Open(KKKK) & Open the specified workbook

**eole.visible=.t. & Show Excel window

eole.visible=.F. & Do not display the Excel window

eole.selection.WrapText = .T.

xlSheet=eole.Sheets(1)

i=1

***Note: Variable I can be the first row or the Nth row. It is up to the user to decide which row the data starts from.

XMH=xlSheet.Cells(I,1).value

***The current data in EXECL is the first column, which can be modified to any N columns

IF TYPE('XMH')'C'

***Note: Determine whether it is a character type. If it is a numeric type, replace 'C' with 'N'

=MESSAGEBOX ('Item number is not character data! Cannot be loaded', 0, 'Prompt message')

eole.ActiveWorkbook.Close(.T.)

eole.Workbooks.close & Close workbook

eole.quit & Exit Excel

RETURN

ENDIF

DO WHILE !EMPTY(XMH)

***When the variable XMH is empty, the reading program ends

SELE SVC

*** SVC is the target table and can also be used as a table with other names

APPE BLAN

REPL project number WITH TRIM(XMH)

***Item number is the target field

XMMC=xlSheet.Cells(I,1).value

I=I 1

XMH=xlSheet.Cells(I,1).value

IF TYPE('XMH')='C'

ELSE

=MESSAGEBOX ('Item number is not character data! Cannot be loaded', 0, 'Prompt message')

eole.ActiveWorkbook.Close(.T.)

eole.Workbooks.close & Close workbook

eole.quit & Exit Excel

RETURN

EXIT

ENDIF

ENDDO

eole.ActiveWorkbook.Close(.T.)

eole.Workbooks.close & Close workbook

eole.quit & Exit Excel

The above is the detailed content of How to write the code to add data to the form in VFP form?. For more information, please follow other related articles on the PHP Chinese website!

source:docexcel.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template