Advertisement
kqlul123

sssssq

May 13th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.17 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Private Type Gold
  4. countryname As String * 15
  5. year(5) As Integer
  6. max As Integer
  7. maxyear As Integer
  8. average As Integer
  9. End Type
  10.  
  11. Dim a1 As Gold
  12. Dim a2 As Gold
  13. Dim cout As String
  14. Dim endl As String
  15. Dim n As Integer
  16. Dim ind As Integer
  17. Dim sum As Currency
  18. Dim k As Integer
  19. Dim summ As Currency
  20. Dim s As String
  21. Dim c As String
  22. Dim nom As Integer
  23. Dim st As String
  24.  
  25.  
  26.  
  27.  
  28. Private Sub btnDelete_Click()
  29. ind = ListBox1.ListIndex
  30. ListBox1.RemoveItem ind
  31. btnDelete.Enabled = False
  32. btnEdit.Enabled = False
  33.  
  34.  
  35. Dim j As Integer
  36. TB1.Enabled = True
  37. TB2.Enabled = True
  38. TB3.Enabled = True
  39. TB4.Enabled = True
  40. TB5.Enabled = True
  41. TB6.Enabled = True
  42. btnOK.Enabled = True
  43.  
  44. j = ListBox1.ListIndex
  45. st = ListBox1.List(j)
  46. Form2.Caption = st
  47.  
  48. btnDelete.Enabled = True
  49.  
  50. nom = 1
  51. s = ""
  52. For k = 1 To Len(st)
  53. c = Mid(st, k, 1)
  54. If c = " " And s <> " " Then nom = nom + 1: s = " "
  55. If c <> " " Then s = s + c
  56. Select Case nom
  57. Case 1: TB1 = s
  58. Case 2: TB2 = Val(s)
  59. Case 3: TB3 = Val(s)
  60. Case 4: TB4 = Val(s)
  61. Case 4: TB5 = Val(s)
  62. Case 4: TB6 = Val(s)
  63.  
  64. End Select
  65. Next k
  66.  
  67. TB1.Enabled = False
  68. TB2.Enabled = False
  69. TB3.Enabled = False
  70. TB4.Enabled = False
  71. TB5.Enabled = False
  72. TB6.Enabled = False
  73.  
  74.  
  75. End Sub
  76.  
  77. Private Sub btnEdit_Click()
  78. Dim j As Integer
  79. TB1.Enabled = True
  80. TB2.Enabled = True
  81. TB3.Enabled = True
  82. TB4.Enabled = True
  83. TB5.Enabled = True
  84. TB6.Enabled = True
  85. btnOK.Enabled = True
  86.  
  87. j = ListBox1.ListIndex
  88. st = ListBox1.List(j)
  89. Form2.Caption = st
  90.  
  91. btnDelete.Enabled = True
  92.  
  93. nom = 1
  94. s = ""
  95. For k = 1 To Len(st)
  96. c = Mid(st, k, 1)
  97. If c = " " And s <> " " Then nom = nom + 1: s = " "
  98. If c <> " " Then s = s + c
  99. Select Case nom
  100. Case 1: TB1 = s
  101. Case 2: TB2 = Val(s)
  102. Case 3: TB3 = Val(s)
  103. Case 4: TB4 = Val(s)
  104. Case 4: TB5 = Val(s)
  105. Case 4: TB6 = Val(s)
  106.  
  107. End Select
  108. Next k
  109.  
  110. 'ListBox1.RemoveItem j
  111. btnEdit.Enabled = True
  112. btnDelete.Enabled = True
  113.  
  114.  
  115. End Sub
  116.  
  117. Private Sub btnExit_Click()
  118. End
  119. End Sub
  120.  
  121. Private Sub btnInput_Click()
  122. TB1.Enabled = True
  123. TB2.Enabled = True
  124. TB3.Enabled = True
  125. TB4.Enabled = True
  126. TB5.Enabled = True
  127. TB6.Enabled = True
  128. TB1.Text = ""
  129. TB2.Text = ""
  130. TB3.Text = ""
  131. TB4.Text = ""
  132. TB5.Text = ""
  133. TB6.Text = ""
  134. btnInput.Enabled = False
  135. btnOK.Enabled = True
  136.  
  137.  
  138. End Sub
  139.  
  140. Private Sub btnList_Click()
  141. Dim l As Integer
  142. Dim i As Integer
  143.  
  144. l = Len(a1.countryname)
  145. s = a1.countryname + Space(15 - l)
  146. For i = 1 To 5
  147. l = Len(Str(a1.year(i)))
  148. s = s + Str(a1.year(i)) + Space(6 - l)
  149. Next i
  150. l = Len(Str(a1.average))
  151. s = s + Str(a1.average) + Space(7 - l)
  152. l = Len(Str(a1.max))
  153. s = s + Str(a1.max) + Space(8 - l)
  154. l = Len(Str(a1.maxyear))
  155. s = s + Str(a1.maxyear) + Space(8 - l)
  156.  
  157.  
  158. ListBox1.AddItem s
  159. btnO.Enabled = True
  160. btnList.Enabled = False
  161. btnInput.Enabled = True
  162. End Sub
  163.  
  164. Private Sub btnO_Click()
  165. Dim s As String
  166. Dim ssr As Long
  167. Dim sr1 As Long
  168. Dim sr2 As Long
  169. Dim sr3 As Long
  170. Dim sr4 As Long
  171. Dim sr5 As Long
  172. Dim k As Integer
  173. Dim maxindex As Integer
  174. Dim max As Long
  175. Dim nom As Integer
  176. Dim n As Integer
  177. Dim i As Integer
  178. Dim j As Integer
  179. Dim l As Integer
  180. Dim c As String
  181. Dim st As String
  182.  
  183. LabelAvgValue.Visible = True
  184.  
  185. n = ListBox1.ListCount
  186. max = 0
  187. ssr = 0
  188. maxindex = 0
  189.  
  190.  
  191. For i = 0 To n
  192. ind = i
  193. If i = n Then ind = maxindex
  194. st = ListBox1.List(ind)
  195. nom = 0
  196. s = ""
  197. For k = 1 To Len(st)
  198. c = Mid(st, k, 1)
  199. If c <> " " Then s = s + c
  200. If c = " " And s <> "" Then
  201. nom = nom + 1
  202.  
  203. Select Case nom
  204. Case 1: TB1 = s
  205. Case 2: TB2 = Val(s)
  206. Case 3: TB3 = Val(s)
  207. Case 4: TB4 = Val(s)
  208. Case 5: TB5 = Val(s)
  209. Case 6: TB6 = Val(s)
  210. End Select
  211. s = ""
  212. End If
  213. Next k
  214.  
  215.  
  216. 'If a1.average > max Then
  217. 'max = a1.average
  218. 'maxindex = ind
  219. 'End If
  220.  
  221. a1.average = 0
  222. For j = 1 To 5
  223. a1.average = a1.average + a1.year(j)
  224. Next j
  225. a1.average = a1.average / 5
  226.  
  227. If i < n Then
  228. sr1 = sr1 + a1.year(1)
  229. sr2 = sr2 + a1.year(2)
  230. sr3 = sr3 + a1.year(3)
  231. sr4 = sr4 + a1.year(4)
  232. sr5 = sr5 + a1.year(5)
  233. ssr = ssr + a1.average
  234. End If
  235. Next i
  236.  
  237. If n > 0 Then
  238. sr1 = sr1 / n
  239. sr2 = sr2 / n
  240. sr3 = sr3 / n
  241. sr4 = sr4 / n
  242. sr5 = sr5 / n
  243. ssr = ssr / n
  244. End If
  245.  
  246.  
  247.  
  248. l = Len(Str(sr1))
  249. s = s + Str(sr1) + Space(13 - 1)
  250. l = Len(Str(sr2))
  251. s = s + Str(sr2) + Space(13 - 1)
  252. l = Len(Str(sr3))
  253. s = s + Str(sr3) + Space(13 - 1)
  254. l = Len(Str(sr4))
  255. s = s + Str(sr4) + Space(13 - 1)
  256. l = Len(Str(sr5))
  257. s = s + Str(sr5) + Space(13 - 1)
  258. l = Len(ssr)
  259. s = s + Str(ssr) + Space(13 - 1)
  260. LabelAVG.Caption = s
  261.  
  262.  
  263.  
  264. End Sub
  265.  
  266. Private Sub btnOK_Click()
  267. endl = Chr(13) + Chr(10)
  268. Dim i As Integer
  269. a1.average = 0
  270. For i = 1 To 5
  271. a1.average = a1.average + a1.year(i)
  272. Next i
  273. a1.average = a1.average / 5
  274.  
  275. a1.max = a1.year(1)
  276. a1.maxyear = 1
  277. If a1.year(2) > a1.max Then a1.max = a1.year(2): a1.maxyear = 2
  278. If a1.year(3) > a1.max Then a1.max = a1.year(3): a1.maxyear = 3
  279. If a1.year(4) > a1.max Then a1.max = a1.year(4): a1.maxyear = 4
  280. If a1.year(5) > a1.max Then a1.max = a1.year(5): a1.maxyear = 5
  281.  
  282. btnList.Enabled = True
  283.  
  284.  
  285. cout = "Íàçâàíèå còðàíû: " + a1.countryname + endl
  286. cout = cout + "Çîëîòîäîáû÷à:" + endl
  287. cout = cout + "Ãîä 1 - " + Str(a1.year(1)) + endl
  288. cout = cout + "Ãîä 2 - " + Str(a1.year(2)) + endl
  289. cout = cout + "Ãîä 3 - " + Str(a1.year(3)) + endl
  290. cout = cout + "Ãîä 4 - " + Str(a1.year(4)) + endl
  291. cout = cout + "Ãîä 5 - " + Str(a1.year(5)) + endl
  292. cout = cout + "Ñðåäíÿÿ çîëîòîäîáû÷à - " + Str(a1.average) + endl
  293. cout = cout + "Ìàêñèìàëüíàÿ çîëîòîäîáû÷à - " + Str(a1.max) + endl
  294. cout = cout + "Ãîä ñ ìàêñ. çîëîòîäîáû÷åé - " + Str(a1.maxyear) + endl
  295.  
  296. For i = 1 To 5
  297. summ = summ + a1.year(i)
  298. Next i
  299.  
  300. lbOut.Caption = "Çîëîòîäîáû÷à çà 5 ëåò: " + Str(summ)
  301. TB1.Enabled = False
  302. TB2.Enabled = False
  303. TB3.Enabled = False
  304. TB4.Enabled = False
  305. TB5.Enabled = False
  306. TB6.Enabled = False
  307.  
  308. btnOK.Enabled = False
  309. btnList.Enabled = True
  310. btnInput.Caption = "Äîáàâèòü çàïèñü"
  311. End Sub
  312.  
  313.  
  314.  
  315.  
  316.  
  317. Private Sub Label1_Click()
  318.  
  319. End Sub
  320.  
  321. Private Sub LabelAVG_Click()
  322.  
  323. End Sub
  324.  
  325. Private Sub lb6_Click()
  326.  
  327. End Sub
  328.  
  329. Private Sub lb8_Click()
  330.  
  331. End Sub
  332.  
  333. Private Sub lb9_Click()
  334.  
  335. End Sub
  336.  
  337. Private Sub LB10_Click()
  338.  
  339. End Sub
  340.  
  341. Private Sub lb11_Click()
  342.  
  343. End Sub
  344.  
  345. Private Sub lb12_Click()
  346.  
  347. End Sub
  348.  
  349. Private Sub lb13_Click()
  350.  
  351. End Sub
  352.  
  353. Private Sub lb14_Click()
  354.  
  355. End Sub
  356.  
  357. Private Sub lb15_Click()
  358.  
  359. End Sub
  360.  
  361. Private Sub lb16_Click()
  362.  
  363. End Sub
  364.  
  365. Private Sub ListBox1_Click()
  366. Dim j As Integer
  367.  
  368.  
  369.  
  370.  
  371. j = ListBox1.ListIndex
  372. st = ListBox1.List(j)
  373. Form2.Caption = st
  374.  
  375.  
  376. nom = 1
  377. s = ""
  378. For k = 1 To Len(st)
  379. c = Mid(st, k, 1)
  380. If c = " " And s <> " " Then nom = nom + 1: s = " "
  381. If c <> " " Then s = s + c
  382. Select Case nom
  383. Case 1: TB1 = s
  384. Case 2: TB2 = Val(s)
  385. Case 3: TB3 = Val(s)
  386. Case 4: TB4 = Val(s)
  387. Case 5: TB5 = Val(s)
  388. Case 6: TB6 = Val(s)
  389.  
  390. End Select
  391. Next k
  392.  
  393. btnEdit.Enabled = True
  394. btnDelete.Enabled = True
  395. End Sub
  396.  
  397. Private Sub TB1_Change()
  398. a1.countryname = TB1
  399. End Sub
  400.  
  401. Private Sub TB2_Change()
  402. a1.year(1) = Val(TB2)
  403. End Sub
  404.  
  405. Private Sub TB3_Change()
  406. a1.year(2) = Val(TB3)
  407. End Sub
  408.  
  409. Private Sub TB4_Change()
  410. a1.year(3) = Val(TB4)
  411. End Sub
  412.  
  413. Private Sub TB5_Change()
  414. a1.year(4) = Val(TB5)
  415. End Sub
  416.  
  417. Private Sub TB6_Change()
  418. a1.year(5) = Val(TB6)
  419. End Sub
  420.  
  421. Private Sub form_Click()
  422.  
  423. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement