Cov txheej txheem:

Quadratic Equation Macro ntawm Excel: 3 Kauj Ruam
Quadratic Equation Macro ntawm Excel: 3 Kauj Ruam

Video: Quadratic Equation Macro ntawm Excel: 3 Kauj Ruam

Video: Quadratic Equation Macro ntawm Excel: 3 Kauj Ruam
Video: Make a Solver for Quadratic Equations by Excel VBA Programming 2024, Kaum ib hlis
Anonim
Quadratic Equation Macro ntawm Excel
Quadratic Equation Macro ntawm Excel

koj tuaj yeem yooj yim daws qhov sib npaug ntawm plaub los ntawm tsuas yog mus rau cov cuab yeej-macro-khiav macro. Kuv yog tus tswv cuab tshiab thiab xav tau txhua yam kev tawm tswv yim uas koj tuaj yeem muab tau.

Kauj Ruam 1: Teeb Khoom

Teeb Khoom
Teeb Khoom

qhib tau zoo txhua xyoo yog qhov ua tau zoo (nyiam 03 qhov ntawd yog qhov kuv tau siv los ua qhov macro no). Yog tias koj siv excel 07 nws yuav raug saib thiab yuav muaj lub thawv me me uas hais tias macro. Nyem rau lub cim thiab mus rau cov ntaub ntawv macro lub qhov rai yuav tshwm nws yuav teeb lub npe thiab piav qhia ntawm lub macro. Tom qab koj ua qhov ntawd nyem rau ntawm lub cim macro dua thiab lwm lub qhov rai yuav tshwm sim yuav tsum muaj nyob rau hauv lub qhov rais lub npe ntawm macro muaj (lub npe lub npe yuav yog Macro1)

Kauj ruam 2: Ua Macro

Ua Macro
Ua Macro

Okay tam sim no koj mus kho ntawm lub qhov rais uas tau tshwm sim nws yuav tsum yog nyob rau sab xis sab xis thib peb. Thaum koj nias lub pob hloov kho tag nrho lub qhov rai tshiab yuav tshwm sim hu ua visual basic editor. Yuav tsum muaj lub cuab yeej thiab txhua yam zoo li txhua lub qhov rai, tab sis hauv lub qhov rai yuav tsum muaj thaj chaw loj loj nrog lub qhov rais hu ua Module1 (Code). Sab hauv Module1 nyem raws li koj yuav tau ntaus nws thiab luam thiab muab qhov no tso rau nws (ua foob koj rho tawm txhua yam ua ntej koj ua qhov no ntawm Module1 lub thawv.) Sub QuadraticFormula () Dim Dim As Long Dim b As Long Dim c As Long MsgBox prompt: = "ax2 + bx + c = 0 ", _x Title: = "Solving a Quadratic Polynomial of the Form:" a = Application. InputBox (prompt: = "Enter the value of the 'a' coefficient", Type: = 1) b = ApplicationInputBox (prompt: = "Nkag mus tus nqi ntawm 'b' coefficient ", Hom: = 1) c = ApplicationInputBox (sai: =" Sau tus nqi ntawm 'c' coefficient ", Hom: = 1) Yog a = 0 Tom qab ntawd MsgBox" Cov kab zauv is not quadratic "Else If ((b * b) - (4 * a * c))> = 0 Ces MsgBox ((-b + (Sqr ((b * b) - (4 * a * c))))) / (2 * a)) MsgBox ((-b - (Sqr ((b * b) - (4 * a * c))))) / (2 * a)) Lwm MsgBox "Tsis Muaj Tshuaj Tiag - Xav Txog Qhov Kawg" End IfEnd Sub

Kauj ruam 3: Ua tiav

Tiav tiav
Tiav tiav

Thaum lub qhov rai ntawd muaj txhua yam kuv hais rau koj theej thiab muab kaw kaw VIsual Basic Editor. Thaum kawg mus rau macro-saib macros tom qab ntawv mus rau sab xis sab xub thawj. Yuav tsum muaj lub qhov rai uas pops nyem OK ces lwm lub thawv yuav tshwm uas yuav yog tus nqi ntawm A hauv kab zauv ces lwm qhov uas yuav yog tus nqi B hauv qhov kev ua zauv thiab tom qab ntawd lwm qhov uas yuav yog tus nqi ntawm C. Koj ua tiav yog tias koj muaj teeb meem thov qhia rau kuv thiab thov tawm qee qhov lus teb rau kuv.

Pom zoo: