PowerBuilder Calculator
Source code
w_calculator from window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | forward global type w_calculator from window end type type sle_2 from singlelineedit within w_calculator end type type sle_1 from singlelineedit within w_calculator end type type cb_digitdot from commandbutton within w_calculator end type type cb_equal from commandbutton within w_calculator end type type cb_divide from commandbutton within w_calculator end type type cb_multiply from commandbutton within w_calculator end type type cb_minus from commandbutton within w_calculator end type type cb_plus from commandbutton within w_calculator end type type cb_digit0 from commandbutton within w_calculator end type type cb_digit9 from commandbutton within w_calculator end type type cb_digit6 from commandbutton within w_calculator end type type cb_digit5 from commandbutton within w_calculator end type type cb_digit8 from commandbutton within w_calculator end type type cb_digit7 from commandbutton within w_calculator end type type cb_digit4 from commandbutton within w_calculator end type type cb_digit3 from commandbutton within w_calculator end type type cb_digit2 from commandbutton within w_calculator end type type cb_digit1 from commandbutton within w_calculator end type type cb_ce from commandbutton within w_calculator end type end forward global type w_calculator from window integer width = 809 integer height = 1020 boolean titlebar = true string title = "Calculator" boolean controlmenu = true boolean resizable = true long backcolor = 67108864 string icon = "AppIcon!" boolean center = true sle_2 sle_2 sle_1 sle_1 cb_digitdot cb_digitdot cb_equal cb_equal cb_divide cb_divide cb_multiply cb_multiply cb_minus cb_minus cb_plus cb_plus cb_digit0 cb_digit0 cb_digit9 cb_digit9 cb_digit6 cb_digit6 cb_digit5 cb_digit5 cb_digit8 cb_digit8 cb_digit7 cb_digit7 cb_digit4 cb_digit4 cb_digit3 cb_digit3 cb_digit2 cb_digit2 cb_digit1 cb_digit1 cb_ce cb_ce end type global w_calculator w_calculator type variables Decimal add1 // store operands Char s1 // store operator Int flag //Check if the calculation is complete end variables forward prototypes public subroutine wf_operator (commandbutton cba) public subroutine wf_digit (commandbutton cba) end prototypes public subroutine wf_operator (commandbutton cba);//==================================================================== // Function: w_calculator.wf_operator() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value commandbutton cba //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2021/06/18 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Choose Case s1 Case '*' sle_2.Text = String(Dec(sle_2.Text)*add1) Case '/' sle_2.Text = String(add1/Dec(sle_2.Text)) Case '+' sle_2.Text = String(Dec(sle_2.Text)+add1) Case '-' sle_2.Text = String(add1 - Dec(sle_2.Text)) End Choose add1 = Dec(sle_2.Text) //Retain intermediate results s1 = cba.Text // keep the operator just pressed Flag = 0 //Ready to enter the next number sle_1.Text = sle_1.Text+cba.Text end subroutine public subroutine wf_digit (commandbutton cba);//==================================================================== // Function: w_calculator.wf_digit() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value commandbutton cba //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2021/06/18 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== If flag = 0 Then Sle_2.Text = "" //Clear the contents of the sle_2.text text box flag = 1 // End If /* If you don't judge, after you click the = button for the first time, you can start the second calculation without clicking the ce button. The value displayed on the text box will be the result of your first calculation and the value you just clicked, displayed together; (The result of the first calculation is 10, you clicked 3, the text box shows 103) */ If s1 = "=" Then sle_1.Text = " " s1 = "" End If sle_1.Text = sle_1.Text+cba.Text Sle_2.Text = Sle_2.Text+cba.Text end subroutine on w_calculator.create this.sle_2=create sle_2 this.sle_1=create sle_1 this.cb_digitdot=create cb_digitdot this.cb_equal=create cb_equal this.cb_divide=create cb_divide this.cb_multiply=create cb_multiply this.cb_minus=create cb_minus this.cb_plus=create cb_plus this.cb_digit0=create cb_digit0 this.cb_digit9=create cb_digit9 this.cb_digit6=create cb_digit6 this.cb_digit5=create cb_digit5 this.cb_digit8=create cb_digit8 this.cb_digit7=create cb_digit7 this.cb_digit4=create cb_digit4 this.cb_digit3=create cb_digit3 this.cb_digit2=create cb_digit2 this.cb_digit1=create cb_digit1 this.cb_ce=create cb_ce this.Control[]={this.sle_2,& this.sle_1,& this.cb_digitdot,& this.cb_equal,& this.cb_divide,& this.cb_multiply,& this.cb_minus,& this.cb_plus,& this.cb_digit0,& this.cb_digit9,& this.cb_digit6,& this.cb_digit5,& this.cb_digit8,& this.cb_digit7,& this.cb_digit4,& this.cb_digit3,& this.cb_digit2,& this.cb_digit1,& this.cb_ce} end on on w_calculator.destroy destroy(this.sle_2) destroy(this.sle_1) destroy(this.cb_digitdot) destroy(this.cb_equal) destroy(this.cb_divide) destroy(this.cb_multiply) destroy(this.cb_minus) destroy(this.cb_plus) destroy(this.cb_digit0) destroy(this.cb_digit9) destroy(this.cb_digit6) destroy(this.cb_digit5) destroy(this.cb_digit8) destroy(this.cb_digit7) destroy(this.cb_digit4) destroy(this.cb_digit3) destroy(this.cb_digit2) destroy(this.cb_digit1) destroy(this.cb_ce) end on event open;sle_2.SetFocus() end event type sle_2 from singlelineedit within w_calculator integer x = 37 integer y = 120 integer width = 695 integer height = 96 integer taborder = 180 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 boolean border = false boolean displayonly = true end type type sle_1 from singlelineedit within w_calculator integer x = 37 integer y = 32 integer width = 695 integer height = 96 integer taborder = 190 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 boolean border = false boolean displayonly = true end type type cb_digitdot from commandbutton within w_calculator integer x = 402 integer y = 768 integer width = 146 integer height = 112 integer taborder = 120 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "." end type event clicked;wf_digit(This) end event type cb_equal from commandbutton within w_calculator integer x = 585 integer y = 768 integer width = 146 integer height = 112 integer taborder = 170 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "=" boolean default = true end type event clicked;wf_operator(This) end event type cb_divide from commandbutton within w_calculator integer x = 585 integer y = 640 integer width = 146 integer height = 112 integer taborder = 160 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "/" end type event clicked;wf_operator(This) end event type cb_multiply from commandbutton within w_calculator integer x = 585 integer y = 512 integer width = 146 integer height = 112 integer taborder = 150 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "*" end type event clicked;wf_operator(This) end event type cb_minus from commandbutton within w_calculator integer x = 585 integer y = 384 integer width = 146 integer height = 112 integer taborder = 140 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "-" end type event clicked;wf_operator(This) end event type cb_plus from commandbutton within w_calculator integer x = 585 integer y = 256 integer width = 146 integer height = 112 integer taborder = 130 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "+" end type event clicked;wf_operator(This) end event type cb_digit0 from commandbutton within w_calculator integer x = 37 integer y = 768 integer width = 329 integer height = 112 integer taborder = 110 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "0" end type event clicked;wf_digit(This) end event type cb_digit9 from commandbutton within w_calculator integer x = 402 integer y = 640 integer width = 146 integer height = 112 integer taborder = 100 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "9" end type event clicked;wf_digit(This) end event type cb_digit6 from commandbutton within w_calculator integer x = 402 integer y = 512 integer width = 146 integer height = 112 integer taborder = 70 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "6" end type event clicked;wf_digit(This) end event type cb_digit5 from commandbutton within w_calculator integer x = 219 integer y = 512 integer width = 146 integer height = 112 integer taborder = 60 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "5" end type event clicked;wf_digit(This) end event type cb_digit8 from commandbutton within w_calculator integer x = 219 integer y = 640 integer width = 146 integer height = 112 integer taborder = 90 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "8" end type event clicked;wf_digit(This) end event type cb_digit7 from commandbutton within w_calculator integer x = 37 integer y = 640 integer width = 146 integer height = 112 integer taborder = 80 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "7" end type event clicked;wf_digit(This) end event type cb_digit4 from commandbutton within w_calculator integer x = 37 integer y = 512 integer width = 146 integer height = 112 integer taborder = 50 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "4" end type event clicked;wf_digit(This) end event type cb_digit3 from commandbutton within w_calculator integer x = 402 integer y = 384 integer width = 146 integer height = 112 integer taborder = 40 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "3" end type event clicked;wf_digit(This) end event type cb_digit2 from commandbutton within w_calculator integer x = 219 integer y = 384 integer width = 146 integer height = 112 integer taborder = 30 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "2" end type event clicked;wf_digit(This) end event type cb_digit1 from commandbutton within w_calculator integer x = 37 integer y = 384 integer width = 146 integer height = 112 integer taborder = 20 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "1" end type event clicked;wf_digit(This) end event type cb_ce from commandbutton within w_calculator integer x = 37 integer y = 256 integer width = 512 integer height = 112 integer taborder = 10 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "CE" end type event clicked;add1 = 0 s1 = '' flag = 0 sle_1.Text = '' sle_2.Text = '' end event |
Find Projects On Github click here
Good Luck!
I’m curious to find out what blog platform you have been using?
I’m experiencing some small security issues with my latest website and I’d like to find something more secure.
Do you have any recommendations?