Guest User

LaB

a guest
May 10th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.18 KB | None | 0 0
  1. Calculator:
  2. Option Explicit
  3. Dim operand1 As Double, operand2 As Double
  4. Dim op1 As Double, op2 As Double
  5. Dim operator As String
  6. Dim cleardisplay As Boolean
  7.  
  8. Private Sub cmdclear_Click()
  9. display.Caption = ""
  10. End Sub
  11.  
  12. Private Sub cmddiv_Click()
  13. op1 = Val(display.Caption)
  14. operator = "/"
  15. display.Caption = ""
  16. End Sub
  17.  
  18. Private Sub cmddot_Click()
  19. If InStr(display.Caption, ".") Then
  20. Exit Sub
  21. Else
  22. display.Caption = display.Caption + "."
  23. End If
  24. End Sub
  25.  
  26. Private Sub cmdequal_Click()
  27. Dim result As Double
  28. op2 = Val(display.Caption)
  29. If operator = "+" Then
  30. result = add(ByVal op1, ByVal op2)
  31. End If
  32. If operator = "-" Then
  33. result = subtract(ByVal op1, ByVal op2)
  34. End If
  35. If operator = "*" Then
  36. result = mul(ByVal op1, ByVal op2)
  37. End If
  38. If operator = "/" Then
  39. result = div(ByVal op1, ByVal op2)
  40. End If
  41. display.Caption = result
  42. End Sub
  43.  
  44. Private Sub cmdminus_Click()
  45. op1 = Val(display.Caption)
  46. operator = "-"
  47. display.Caption = ""
  48. End Sub
  49.  
  50. Private Sub cmdmul_Click()
  51. op1 = Val(display.Caption)
  52. operator = "*"
  53. display.Caption = ""
  54. End Sub
  55.  
  56. Private Sub cmdplus_Click()
  57. op1 = Val(display.Caption)
  58. operator = "+"
  59. display.Caption = ""
  60. End Sub
  61.  
  62. Private Function add(ByVal operand1 As Double, ByVal operand2 As Double) As Double
  63. add = operand1 + operand2
  64. End Function
  65.  
  66. Private Sub digit_Click(Index As Integer)
  67. If cleardisplay Then
  68. display.Caption = ""
  69. cleardisplay = False
  70. End If
  71. display.Caption = display.Caption + digit(Index).Caption
  72. End Sub
  73.  
  74.  
  75. Private Function subtract(ByVal operand1 As Double, ByVal operand2 As Double) As Double
  76. subtract = operand1 - operand2
  77. End Function
  78.  
  79. Private Function mul(ByVal operand1 As Double, ByVal operand2 As Double) As Double
  80. mul = operand1 * operand2
  81.  
  82. End Function
  83.  
  84. Private Function div(ByVal operand1 As Double, ByVal operand2 As Double) As Double
  85. div = operand1 / operand2
  86.  
  87. End Function
  88.  
  89.  
  90. Alarm Clock:
  91. Private Sub cmdexit_Click()
  92. Unload Me
  93. End Sub
  94.  
  95. Private Sub cmdset_Click()
  96. Label2.Caption = Text1.Text
  97. End Sub
  98.  
  99. Private Sub cmdstart_Click()
  100. Timer1.Enabled = True
  101. End Sub
  102.  
  103.  
  104.  
  105. Private Sub Text1_GotFocus()
  106. Text1.Text = "00:00:00"
  107. End Sub
  108.  
  109. Private Sub Timer1_Timer()
  110. If Format(Time, "hh:mm:ss") = Label2.Caption Then
  111. 'beep
  112. MsgBox ("good moring")
  113. End If
  114.  
  115. End Sub
  116.  
  117. Private Sub Timer2_Timer()
  118. Label1.Caption = Format(Time, "hh:mm:ss")
  119. End Sub
  120.  
  121. Employee Details:
  122. Private Sub cmdclear_Click()
  123. Text1.Text = " "
  124. Text2.Text = " "
  125. Text3.Text = " "
  126. Text4.Text = " "
  127. Text5.Text = " "
  128. Text6.Text = " "
  129. Text7.Text = " "
  130. Text8.Text = " "
  131. Text9.Text = " "
  132. Text1.SetFocus
  133.  
  134. End Sub
  135.  
  136. Private Sub cmdexit_Click()
  137. Unload Me
  138. End Sub
  139.  
  140. Private Sub cmdresult_Click()
  141. Dim bp, da, hra, ded, gp, np As Integer
  142. If Text1.Text = " " Or Text2.Text = " " Or Text3.Text = " " Or Text4.Text = " " Then
  143. MsgBox "fieids cannot be left blank"
  144. Text1.SetFocus
  145. End If
  146. bp = Val(Text4.Text)
  147. Select Case bp
  148. Case 0 To 2000
  149. da = 2 / 100 * bp
  150. hra = 3 / 100 * bp
  151. ded = 50
  152. Text5.Text = Val(da)
  153. Text6.Text = Val(hra)
  154. Text7.Text = Val(ded)
  155. Case 2000 To 5000
  156. da = 4 / 100 * bp
  157. hra = 5 / 100 * bp
  158. ded = 100
  159. Text5.Text = Val(da)
  160. Text6.Text = Val(hra)
  161. Text7.Text = Val(ded)
  162. Case 5001 To 10000
  163. Text7.Text = Val(ded)
  164. Case ls > 10000
  165. da = 8 / 100 * bp
  166. hra = 9 / 100 * bp
  167. ded = 1500
  168. Text5.Text = Val(da)
  169. Text6.Text = Val(hra)
  170. Text7.Text = Val(ded)
  171. Case Else
  172. MsgBox "enter the basic pay"
  173. End Select
  174. gp = bp + da + hra
  175. Text8.Text = Val(gp)
  176. np = gp - ded
  177. Text9.Text = Val(np)
  178. End Sub
  179.  
  180.  
  181.  
  182. Private Sub Text4_KeyPress(KeyAscii As Integer)
  183. If (KeyAscii < 48 And KeyAscii > 46 And KeyAscii <> 8) Or (KeyAscii > 57) Then
  184. KeyAscii = 0
  185. MsgBox "enter numeric value"
  186. Text4.SetFocus
  187. End If
  188. End Sub
  189.  
  190. Student Details:
  191.  
  192. Private Sub calculate_Click()
  193. Dim a As Integer
  194. If (Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "") Then
  195. MsgBox "field should not be left blank"
  196. Exit Sub
  197. End If
  198. a = Val(Text3) + Val(Text4) + Val(Text5)
  199. Label10.Caption = a
  200. b = a / 3
  201. Label11.Caption = b
  202. If (b < 40) Then
  203. Label12.Caption = "FAIL"
  204. ElseIf (b < 60) Then
  205. Label12.Caption = "SECOND"
  206. ElseIf (b < 75) Then
  207. Label12.Caption = "FIRST"
  208. Else
  209. Label12.Caption = "DISTINCTION"
  210. End If
  211. End Sub
  212.  
  213. Private Sub Clear_Click()
  214. Text1.Text = ""
  215. Text2.Text = ""
  216. Text3.Text = ""
  217. Text4.Text = ""
  218. Text5.Text = ""
  219. Label10.Caption = ""
  220. Label11.Caption = ""
  221. Label12.Caption = ""
  222. Text1.SetFocus
  223. End Sub
  224.  
  225.  
  226. Private Sub exit_Click()
  227. Unload Me
  228. End Sub
  229.  
  230. Private Sub Text1_KeyPress(KeyAscii As Integer)
  231. If KeyAscii = 13 And Text1.Text <> "" Then
  232. Text2.SetFocus
  233. ElseIf (KeyAscii < 65 And KeyAscii <> 8 And KeyAscii <> 32) Or (KeyAscii > 90 And KeyAscii < 97) Or (KeyAscii > 122) Then
  234. KeyAscii = 0
  235. MsgBox "enter letter only"
  236. End If
  237. End Sub
  238.  
  239.  
  240. Private Sub Text2_KeyPress(KeyAscii As Integer)
  241. If KeyAscii = 13 And Text2.Text <> "" Then
  242. Text3.SetFocus
  243. ElseIf (KeyAscii < 65 And KeyAscii <> 8 And KeyAscii <> 32) Or (KeyAscii > 90 And KeyAscii < 97) Or (KeyAscii > 122) Then
  244. KeyAscii = 0
  245. MsgBox "enter letter only"
  246. End If
  247. End Sub
  248.  
  249.  
  250. Private Sub Text3_Change()
  251. If Val(Text3.Text) > 100 Then
  252. MsgBox "marks range from 0 to 100"
  253. Text3.Text = ""
  254. End If
  255. End Sub
  256.  
  257. Private Sub Text3_KeyPress(KeyAscii As Integer)
  258. If KeyAscii = 13 And Text3.Text <> "" Then
  259. Text4.SetFocus
  260. ElseIf (KeyAscii < 48 And KeyAscii <> 8) Or KeyAscii > 57 Then
  261. KeyAscii = 0
  262. MsgBox "enter Digits only"
  263. End If
  264. End Sub
  265.  
  266. Private Sub Text4_Change()
  267. If Val(Text4.Text) > 100 Then
  268. MsgBox "marks range from 0 to 100"
  269. Text4.Text = ""
  270. End If
  271. End Sub
  272.  
  273. Private Sub Text4_KeyPress(KeyAscii As Integer)
  274. If KeyAscii = 13 And Text4.Text <> "" Then
  275. Text5.SetFocus
  276. ElseIf (KeyAscii < 48 And KeyAscii <> 8) Or KeyAscii > 57 Then
  277. KeyAscii = 0
  278. MsgBox "enter Digits only"
  279. End If
  280. End Sub
  281.  
  282. Private Sub Text5_Change()
  283. If Val(Text5.Text) > 100 Then
  284. MsgBox "marks range from 0 to 100"
  285. Text5.Text = ""
  286. End If
  287. End Sub
  288.  
  289. Private Sub Text5_KeyPress(KeyAscii As Integer)
  290. If KeyAscii = 13 And Text5.Text <> "" Then
  291. calculate.SetFocus
  292. ElseIf (KeyAscii < 48 And KeyAscii <> 8) Or KeyAscii > 57 Then
  293. KeyAscii = 0
  294. MsgBox "enter Digits only"
  295. End If
  296. End Sub
  297.  
  298. User Login:
  299. Dim rs As New ADODB.Recordset
  300. Dim conn As New ADODB.Connection
  301.  
  302.  
  303. Private Sub cmdexit_Click()
  304. MsgBox "do u really want to exit", vbInformation + vbOKOnly, "table1"
  305. If vbOK Then
  306. End
  307. End If
  308. End Sub
  309.  
  310. Private Sub cmdlogin_Click()
  311. If Text1.Text = " " Then
  312. MsgBox "enter the username", vbInformation + vbOKOnly, "table1"
  313. Text1.SetFocus
  314. Exit Sub
  315. End If
  316. If Text2.Text = " " Then
  317. MsgBox "enter the password", vbInformation + vbOKOnly, "table1"
  318. Text2.SetFocus
  319. Exit Sub
  320. End If
  321. If Text1.Text <> "" And Text2.Text <> "" Then
  322. If rs.State = 1 Then
  323. rs.Close
  324. Else
  325. rs.Open "select * from table1 where username='" & Text1 & "' and password='" & Text2 & "'", conn, adOpenDynamic, adLockOptimistic, adCmdText
  326. End If
  327. If rs.EOF = True Then
  328. MsgBox "invalid username and password", vbCritical + vbOKOnly, "table1"
  329. Text1.Text = " "
  330. Text2.Text = " "
  331. Text1.SetFocus
  332. Else
  333. MsgBox "username and password correct", vbInformation + vbOKOnly, "table1"
  334. End If
  335. End If
  336. End Sub
  337.  
  338. Private Sub Form_Load()
  339. conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\user2\user99.mdb;Persist Security Info=False"
  340. End Sub
  341. Library Database:
  342. Private Sub cmdexit_Click()
  343. End
  344. End Sub
  345.  
  346. Private Sub Combo1_click()
  347. If Combo1.Text <> "" Then
  348. Adodc1.RecordSource = "select *from table1 where isbn ='" & Combo1.Text & "'"
  349. Adodc1.Refresh
  350. End If
  351. End Sub
  352.  
  353. Private Sub Combo2_click()
  354. If Combo2.Text <> "" Then
  355. Adodc1.RecordSource = "select *from table1 where author ='" & Combo2.Text & "'"
  356. Adodc1.Refresh
  357. End If
  358. End Sub
  359.  
  360. Private Sub Combo3_Click()
  361. If Combo3.Text <> "" Then
  362. Adodc1.RecordSource = "select *from table1 where titile='" & Combo3.Text & "'"
  363. Adodc1.Refresh
  364. End If
  365. End Sub
  366.  
  367. Private Sub Option1_Click()
  368. If Option1.Value = True Then
  369. Combo1.Visible = True
  370. Combo2.Visible = False
  371. Combo3.Visible = False
  372. End If
  373. End Sub
  374.  
  375.  
  376. Private Sub Option2_Click()
  377. If Option2.Value = True Then
  378. Combo1.Visible = False
  379. Combo2.Visible = True
  380. Combo3.Visible = False
  381. End If
  382.  
  383.  
  384.  
  385.  
  386. End Sub
  387.  
  388. Private Sub Option3_Click()
  389. If Option3.Value = True Then
  390. Combo1.Visible = False
  391. Combo2.Visible = False
  392. Combo3.Visible = True
  393. End If
  394.  
  395.  
  396. End Sub
  397.  
  398. Encryption And Decryption
  399.  
  400.  
  401.  
  402. Private Sub Command1_Click()
  403. X = encryptdecrypt(Text1.Text, True)
  404. MsgBox (X)
  405. Text2.Text = X
  406.  
  407. End Sub
  408.  
  409. Private Sub Command2_Click()
  410. X = encryptdecrypt(Text2.Text, False)
  411. MsgBox (X)
  412.  
  413. End Sub
  414.  
  415. Private Sub Command3_Click()
  416. Text1.Text = ""
  417. Text2.Text = ""
  418.  
  419. End Sub
  420.  
  421.  
  422. Private Sub Command4_Click()
  423. Unload Me
  424.  
  425. End Sub
  426.  
  427. Public Function encryptdecrypt(ByVal strval, ByVal blndec As Boolean) As String
  428. Dim int1, int2, int3 As Integer
  429. str1 = strval
  430. int1 = Len(str1)
  431. int2 = 1
  432. Randomize
  433. Do While int2 <> (int1 + 1)
  434. str2 = Mid(str1, int2, 1)
  435. If blndec = True Then
  436. int3 = Asc(str2) - 3
  437. Else
  438. int3 = Asc(str2) + 3
  439. End If
  440. str3 = Chr(int3)
  441. str4 = str4 & str3
  442. int2 = int2 + 1
  443. Loop
  444. encryptdecrypt = str4
  445.  
  446. End Function
  447. Part B
  448.  
  449. 1.Load an Image
  450. Private Sub Dir1_Change()
  451. File1.Path = Dir1.Path
  452. End Sub
  453.  
  454. Private Sub Drive1_Change()
  455. Dir1.Path = Drive1.Drive
  456. End Sub
  457.  
  458. Private Sub File1_Click()
  459. Image1.Picture = LoadPicture("C:\Users\user4\Downloads\tenor.gif")
  460. End Sub
  461.  
  462. Private Sub Form_Load()
  463. File1.Pattern = "*.jpg;*.bmp;*.ico;*.gif;*.wmf"
  464. End Sub
  465. 2.Scroll Bar
  466. Private Sub cmdexit_Click()
  467. Unload Me
  468. End Sub
  469.  
  470. Private Sub HScroll1_Change()
  471. txt1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
  472. txt1.ForeColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
  473. End Sub
  474.  
  475. Private Sub HScroll2_Change()
  476. txt1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
  477. txt1.ForeColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
  478. End Sub
  479.  
  480. Private Sub HScroll3_Change()
  481. txt1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
  482. txt1.ForeColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
  483. End Sub
  484.  
  485. 3.API Viewer
  486. Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As Pointapi) As Long
  487. Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
  488. Private Sub cmdexit_click()
  489. Unload Me
  490. End Sub
  491. Private Sub cmdclick_click()
  492. Dim ptapi As Pointapi
  493. retval = MoveToEx(Picture1.hdc, 20, 20, ptapi)
  494. retval = LineTo(Picture1.hdc, 100, 80)
  495. End Sub
  496.  
  497. Type Pointapi
  498. x As Long
  499. y As Long
  500. End Type
  501.  
  502. Sequential Search
  503. Private Sub cmddisp_Click()
  504. Dim no As Integer
  505. Grid1.Clear
  506. Grid1.TextMatrix(0, 0) = "slno"
  507. Grid1.TextMatrix(0, 1) = "name"
  508. Grid1.TextMatrix(0, 2) = "address"
  509. Grid1.TextMatrix(0, 3) = "state"
  510. Grid1.TextMatrix(0, 4) = "city"
  511. Grid1.TextMatrix(0, 5) = "pincode"
  512. Grid1.TextMatrix(0, 6) = "phoneno"
  513. Open "C:\Users\user3\Documents\shilpa.txt" For Input As #1
  514. no = 1
  515. slno = 1
  516. While Not EOF(1)
  517. Grid1.Rows = Grid1.Rows + 1
  518. Input #1, v1, v2, v3, v4, v5, v6
  519. Grid1.TextMatrix(no, 0) = slno
  520. Grid1.TextMatrix(no, 1) = v1
  521. Grid1.TextMatrix(no, 2) = v2
  522. Grid1.TextMatrix(no, 3) = v3
  523. Grid1.TextMatrix(no, 4) = v4
  524. Grid1.TextMatrix(no, 5) = v5
  525. Grid1.TextMatrix(no, 6) = v6
  526. no = no + 1
  527. slno = slno + 1
  528. Wend
  529. Close #1
  530. End Sub
  531.  
  532. Private Sub cmdwrite_Click()
  533. Open "C:\Users\user3\Documents\shilpa.txt" For Append As #1
  534. Write #1, txtname, txtaddr, txtstate, txtcity, txtpin, txtphone
  535. Close #1
  536. clrtext
  537.  
  538. End Sub
  539.  
  540.  
  541.  
  542. Private Sub Form_Load()
  543. Grid1.ColWidth(0) = 550
  544. Grid1.ColWidth(1) = 1000
  545. Grid1.ColWidth(2) = 1500
  546. Grid1.ColWidth(3) = 1200
  547. Grid1.ColWidth(4) = 1200
  548. Grid1.ColWidth(5) = 1200
  549. Grid1.ColWidth(6) = 1100
  550. End Sub
  551.  
  552. Private Sub clrtext()
  553. txtname.Text = " "
  554. txtaddr.Text = " "
  555. txtstate.Text = " "
  556. txtcity.Text = " "
  557. txtpin.Text = " "
  558. txtphone.Text = " "
  559.  
  560. End Sub
  561.  
  562. Mouse Pointer
  563.  
  564. Cstring strMessage;
  565. strMessage.Format("Mouse pointer=(%d %d),point.x,point.y);
  566. m_strnmae=strMessage
  567. UpdateData(FALSE)
  568. CDialog::OnMouseMove(nFlags,point)
Add Comment
Please, Sign In to add comment