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?

Jan 17, 2024 pm 12:21 PM

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Discover How to Fix Drive Health Warning in Windows Settings Discover How to Fix Drive Health Warning in Windows Settings Mar 19, 2025 am 11:10 AM

What does the drive health warning in Windows Settings mean and what should you do when you receive the disk warning? Read this php.cn tutorial to get step-by-step instructions to cope with this situation.

How do I edit the Registry? (Warning: Use with caution!) How do I edit the Registry? (Warning: Use with caution!) Mar 21, 2025 pm 07:46 PM

Article discusses editing Windows Registry, precautions, backup methods, and potential issues from incorrect edits. Main issue: risks of system instability and data loss from improper changes.

How do I manage services in Windows? How do I manage services in Windows? Mar 21, 2025 pm 07:52 PM

Article discusses managing Windows services for system health, including starting, stopping, restarting services, and best practices for stability.

How to Fix the Steam Cloud Error? Try These Methods How to Fix the Steam Cloud Error? Try These Methods Apr 04, 2025 am 01:51 AM

The Steam Cloud error can be caused by many reasons. To play a game smoothly, you need to take some measures to remove this error before you launch the game. php.cn Software introduces some best ways as well as more useful information in this post.

Windows Metadata and Internet Services Problem: How to Fix It? Windows Metadata and Internet Services Problem: How to Fix It? Apr 02, 2025 pm 03:57 PM

You may see the “A connection to the Windows Metadata and Internet Services (WMIS) could not be established.” error on Event Viewer. This post from php.cn introduces how to remove the Windows Metadata and Internet Services problem.

How do I change the default app for a file type? How do I change the default app for a file type? Mar 21, 2025 pm 07:48 PM

Article discusses changing default apps for file types on Windows, including reverting and bulk changes. Main issue: no built-in bulk change option.

How to Resolve the KB5035942 Update Issues – Crashing System How to Resolve the KB5035942 Update Issues – Crashing System Apr 02, 2025 pm 04:16 PM

KB5035942 update issues - crashing system commonly happens to users. Inflicted people hope to find a way out of the kind of trouble, such as crashing system, installation, or sound issues. Targeting these situations, this post published by php.cn wil

How do I use the Group Policy Editor (gpedit.msc)? How do I use the Group Policy Editor (gpedit.msc)? Mar 21, 2025 pm 07:48 PM

The article explains how to use the Group Policy Editor (gpedit.msc) in Windows for managing system settings, highlighting common configurations and troubleshooting methods. It notes that gpedit.msc is unavailable in Windows Home editions, suggesting

See all articles