Code
Code
Private Sub Timer1_Timer() Dim X As String Dim Y As String X = Left(text1.Text, 1) Y = Right(text1.Text, Len(text1.Text) - 1) text1.Text = Y + X End Sub
Private Sub mnuExit_Click() End End Sub Private Sub mnuAbout_Click() frmAbout.Show End Sub Private Sub mnuBegin_Click() frmShcp.Show End Sub Private Sub mnuBksh_Click() frmBksh.Show End Sub Private Sub mnuCell_Click() frmCell.Show End Sub Private Sub mnuDlc_Click() frmDlc.Show End Sub Private Sub mnuH_Click() Call HtmlHelp(0, App.Path + "CongTu.chm", HH_display_index, "CongTu.chm") End Sub
Tnh Cell: Private Sub frmCell_load() 'Lay ket qua da tinh' txtdlr.Text = dlcd txtbkr.Text = bk txtdtr.Text = dt End Sub Private Sub mnuAbout_Click() frmAbout.Show End Sub Private Sub mnuBegin_Click() frmmain.Show End Sub Private Sub mnuExit_Click() End End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "new": 'Lay ket qua da tinh' txtdlr.Text = dlcd txtbkr.Text = bk txtdtr.Text = dt 'Thong so thue bao' txtthb(0).Text = "" txtthb(1).Text = "" txtthb(2).Text = "" txtthb(3).Text = "" 'Thong so vung phu' txtbhca(0).Text = ""
txtbhca(1).Text = "" txtbhca(2).Text = "" txtbhca(3).Text = "" 'Ket qua tinh dung luong' txtdl(0).Text = "" txtdl(1).Text = "" txtdl(2).Text = "" txtdl(3).Text = "" 'Ket qua tinh dai quat' txtdq(0).Text = "" txtdq(1).Text = "" txtdq(2).Text = "" txtdq(3).Text = "" 'Ket qua tinh cell theo dung luong' txtcell(0).Text = "" txtcell(1).Text = "" txtcell(2).Text = "" txtcell(3).Text = "" 'Ket qua tinh cell theo dien tich' txtcell(7).Text = "" txtcell(6).Text = "" txtcell(5).Text = "" txtcell(4).Text = "" 'Lay ket qua da tinh' txtdlr.Text = dlcd txtbkr.Text = bk txtdtr.Text = dt Case "recommand": 'Thong so ve dung luong' txtthb(0).Text = "10000" txtthb(1).Text = "5000" txtthb(2).Text = "3200" txtthb(3).Text = "1800" 'Thong so ve vung phu' txtbhca(0).Text = "400" txtbhca(1).Text = "250" txtbhca(2).Text = "200" txtbhca(3).Text = "150" 'Ket qua tinh dung luong' txtdl(0).Text = "" txtdl(1).Text = "" txtdl(2).Text = "" txtdl(3).Text = "" 'Ket qua tinh dai quat' txtdq(0).Text = ""
txtdq(1).Text = "" txtdq(2).Text = "" txtdq(3).Text = "" 'Ket qua tinh cell theo dung luong' txtcell(0).Text = "" txtcell(1).Text = "" txtcell(2).Text = "" txtcell(3).Text = "" 'Ket qua tinh cell theo dien tich' txtcell(7).Text = "" txtcell(6).Text = "" txtcell(5).Text = "" txtcell(4).Text = "" 'Lay ket qua da tinh' txtdlr.Text = dlcd txtbkr.Text = bk txtdtr.Text = dt Case "result": Dim a!, b!, c!, d!, e!, kq! 'Luu ket qua dung luong va vung phu' dla = Val(txtthb(0).Text) dlb = Val(txtthb(1).Text) dlc = Val(txtthb(2).Text) dld = Val(txtthb(3).Text) dta = Val(txtbhca(0).Text) dtb = Val(txtbhca(1).Text) dtc = Val(txtbhca(2).Text) dtd = Val(txtbhca(3).Text) a = dla * 1.38 * 1.4 * 65 / 3600 b = dlb * 1.38 * 1.4 * 65 / 3600 c = dlc * 1.38 * 1.4 * 65 / 3600 d = dld * 1.38 * 1.4 * 65 / 3600 'Tinh dung luong' txtdl(0).Text = Round(a, 2) txtdl(1).Text = Round(b, 2) txtdl(2).Text = Round(c, 2) txtdl(3).Text = Round(d, 2) 'Tinh dai quat' txtdq(0).Text = Round(a / dlcd) txtdq(1).Text = Round(b / dlcd) txtdq(2).Text = Round(c / dlcd) txtdq(3).Text = Round(d / dlcd) 'Tinh cell theo dung luong' txtcell(0).Text = Round(a / dlcd / 2.4) txtcell(1).Text = Round(b / dlcd / 2.4)
txtcell(2).Text = Round(c / dlcd / 2.4) txtcell(3).Text = Round(d / dlcd / 2.4) 'Tinh cell theo dien tich' txtcell(7).Text = Round(dta / dt) txtcell(6).Text = Round(dtb / dt) txtcell(5).Text = Round(dtc / dt) txtcell(4).Text = Round(dtd / dt) 'Luu ket qua tinh cell theo dien tich' celldta = Round(dta / dt) celldtb = Round(dtb / dt) celldtc = Round(dtc / dt) celldtd = Round(dtd / dt) 'Luu ket qua tinh cell theo dung luong' celldla = Val(txtcell(0).Text) celldlb = Val(txtcell(1).Text) celldlc = Val(txtcell(2).Text) celldld = Val(txtcell(3).Text) 'So cell can la' If (celldla > celldta) Then txtcell(11).Text = celldla Else: txtcell(11).Text = celldta End If celltonga = Val(txtcell(11).Text) If (celldlb > celldtb) Then txtcell(10).Text = celldlb Else: txtcell(10).Text = celldtb End If celltongb = Val(txtcell(10).Text) If (celldlc > celldtc) Then txtcell(9).Text = celldlc Else: txtcell(9).Text = celldtc End If celltongc = Val(txtcell(9).Text) If (celldld > celldtd) Then txtcell(8).Text = celldld Else: txtcell(8).Text = celldtd End If celltongd = Val(txtcell(8).Text) txttong.Text = celltonga + celltongb + celltongc + celltongd Case "back": Unload Me frmmain.Visible = False frmDlc.Show Case "next": Unload Me frmmain.Visible = False
frmTU.Show Case "home": Unload Me frmmain.Visible = True frmmain.Show End Select End Sub Private Sub txtdlc_gotFocus() frmdlcdl.txtkq1(0).Text = dlc End Sub
Suy hao cho php: Private Sub cdmHT_Click() frmAbout1.Show End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = vbKeyReturn Then 'B?t phm Enter SendKeys "{TAB}" KeyAscii = 0 'Hu? phm Enter End If End Sub
Private Sub Option1_Click() If Option1.Enabled = True Then 'frmDTshcp.Show' ImaDT.Visible = True Frame4.Visible = False Picture1.Visible = False End If End Sub Private Sub mnuAbout_Click() frmAbout.Show End Sub Private Sub mnuBegin_Click() frmmain.Show End Sub Private Sub mnuExit_Click() End End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "new": 'Thong so truyen dan' txttd(0).Text = "" txttd(1).Text = "" txttd(2).Text = "" 'Thong so tram goc' txttg(0).Text = "" txttg(1).Text = "" txttg(2).Text = "" txttg(3).Text = "" 'Thong so tram di dong' txtd(0).Text = "" txtd(1).Text = "" txtd(2).Text = "" txtd(3).Text = "" txtd(4).Text = "" 'Ket qua suy hao duong truyen cho phep' lblthcp.Caption = "" 'Ket qua cac thong so' lbltan(0).Caption = "" lblnlb(1).Caption = "" lblcdth(2).Caption = "" lblthdt(3).Caption = "" 'Bang ket qua' lbltdb.Caption = "" lblshcp.Caption = "" Case "recommand": txttd(0).Text = "9600" txttd(1).Text = "10.2" txttd(2).Text = "1228800" txttg(0).Text = "15" txttg(1).Text = "2.5" txttg(2).Text = "6.8" txttg(3).Text = "-174" txtd(0).Text = "36" txtd(1).Text = "10" txtd(2).Text = "2" txtd(3).Text = "5" txtd(4).Text = "3" 'Ket qua suy hao duong truyen cho phep' lblthcp.Caption = "" 'Ket qua cac thong so'
lbltan(0).Caption = "" lblnlb(1).Caption = "" lblcdth(2).Caption = "" lblthdt(3).Caption = "" Case "result": Dim TanBS!, NLBmin!, CDTHmin!, THtb!, THcp!, t! R = Val(txttd(0).Text) Ec = Val(txttd(1).Text) Gb = Val(txttg(0).Text) Lc = Val(txttg(1).Text) Eb = Val(txttg(2).Text) No = Val(txttg(3).Text) Pm = Val(txtd(0).Text) Ltx = Val(txtd(1).Text) Lct = Val(txtd(2).Text) Fb = Val(txtd(3).Text) dt = Val(txtd(4).Text) w = Val(txttd(2).Text) 'If ((R < 9600) Or (R > 14000)) Then' ' MsgBox "GIA TRI CUA TOC DO THONG TIN : 9.6KB/S - 2MB/S", vbOKOnly, "LUU Y"' 'Else' 'L = Pm - No - Fb - Eb - 10 * Log(R) / Log(10) + Gb - Lc - Ec - Lct - Ltx - dt + 10 * Log(w / R) / Log(10)' 'Tinh cac ket qua' TanBS = No + Fb NLBmin = TanBS + Eb CDTHmin = NLBmin + 10 * log10(R) THtb = Pm - CDTHmin + Gb - Lc THcp = shcp(dt) 'Hien thi' 'Ket qua cac thong so' lbltan(0).Caption = (Format(TanBS, "0.##")) lblnlb(1).Caption = Format(NLBmin, "0.##") lblcdth(2).Caption = Format(CDTHmin, "0.##") lblthdt(3).Caption = Format(THtb, "0.##") lblthcp.Caption = Format(THcp, "0.##") 'Bang ket qua' lbltdb.Caption = R lblshcp.Caption = THcp 'Luu ket qua suy hao cho phep' shcd = Round(THcp, 2) Case "back": Unload Me frmmain.Visible = True frmmain.Show
Case "home": Unload Me frmmain.Visible = True frmmain.Show Case "next": Unload Me frmmain.Visible = False frmBksh.Show End Select End Sub Dung lng cc: Option Explicit Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long Private Const LB_ITEMFROMPOINT = &H1A9 Private Sub lstErlang_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) Dim lXPoint As Long Dim lYPoint As Long Dim lIndex As Long If Button = 0 Then 'N?u khng c nt no du?c nh?n lXPoint = CLng(X / Screen.TwipsPerPixelX) lYPoint = CLng(Y / Screen.TwipsPerPixelY) With lstErlang lIndex = SendMessage(.hWnd, LB_ITEMFROMPOINT, 0, _ ByVal ((lYPoint * 65536) + lXPoint)) 'Hi?n ToolTip ho?c xa ci tru?c d If (lIndex >= 0) And (lIndex <= .ListCount) Then .ToolTipText = .List(lIndex) Else .ToolTipText = "" End If End With End If End Sub
frmAbout.Show End Sub Private Sub mnuBegin_Click() frmmain.Show End Sub Private Sub mnuExit_Click() End End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "new": 'Xoa cac thong so txtths1(0).Text = "" txtths1(1).Text = "" txtths1(2).Text = "" txtths1(3).Text = "" txtths1(4).Text = "" txtths1(5).Text = "" 'Xoa cac ket qua txtkq1(0).Text = "" txtkq1(1).Text = "" txtkq1(2).Text = "" 'Xoa bang ErlangB va ket qua tra bang ErlangB lstErlang.Clear txtsokenh.Text = "" txtErlang.Text = "" Case "recommand": Dim i! i=1 txtths1(0).Text = "1228800" txtths1(1).Text = R '"9600" txtths1(2).Text = Eb '"6.8" txtths1(3).Text = "0.4" txtths1(4).Text = "0.4" txtths1(5).Text = "2.4" txtkq1(0).Text = "" txtkq1(1).Text = "" txtkq1(2).Text = "" Do While i <= 100 lstErlang.AddItem i lstErlang.AddItem ErlangB1(i) lstErlang.AddItem "" i=i+1
Loop txtsokenh.Text = "" txtErlang.Text = "" Case "result": Dim kq! w = Val(txtths1(0).Text) R = Val(txtths1(1).Text) Eb = Val(txtths1(2).Text) f = Val(txtths1(3).Text) v = Val(txtths1(4).Text) g = Val(txtths1(5).Text) kq = Round(((w / R) * (g / 3)) / (Eb * (1 + f) * v)) hst = hst1(kq) dtn = dtni(hst) txtkq1(0).Text = Round(kq) txtsokenh.Text = Round(kq) dlcd = ErlangB1(kq) txtErlang.Text = dlcd txtkq1(1).Text = Round(hst, 2) txtkq1(2).Text = Round(dtn, 2) lstErlang.Text = dlcd 'lstErlang.Text = kq Case "back": Unload Me frmmain.Visible = True frmBksh.Show Case "home": Unload Me frmmain.Visible = True frmmain.Show Case "next": Unload Me frmmain.Visible = False frmCell.Show End Select End Sub Ti u:
Private Sub mnuAbout_Click() frmAbout.Show End Sub Private Sub mnuBegin_Click() frmmain.Show End Sub Private Sub mnuEx_Click() frmVungkhac.Show End Sub Private Sub mnuExit_Click() End End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "new": 'Xoa Frame dung luong va vung phu' txtdl(0).Text = "" txtdl(1).Text = "" txtdl(2).Text = "" txtdl(3).Text = "" txtdt(0).Text = "" txtdt(1).Text = "" txtdt(2).Text = "" txtdt(3).Text = "" 'Xoa Frame ban kinh va dien tich' txtkqdt(0).Text = "" txtkqbk(0).Text = "" 'Xoa frame mo hinh va vung' txtmh.Text = "" txtvung.Text = "" 'Xoa Frame ket qua chua lap' 'He so tai' txthst(7).Text = "" txthst(6).Text = ""
txthst(5).Text = "" txthst(4).Text = "" 'So thue bao' txtstb(7).Text = "" txtstb(6).Text = "" txtstb(5).Text = "" txtstb(4).Text = "" 'Du tru nhieu' txtdtn(7).Text = "" txtdtn(6).Text = "" txtdtn(5).Text = "" txtdtn(4).Text = "" 'Suy hao cho phep' txtshcd(7).Text = "" txtshcd(6).Text = "" txtshcd(5).Text = "" txtshcd(4).Text = "" 'Ban kinh cell' txtbkc(7).Text = "" txtbkc(6).Text = "" txtbkc(5).Text = "" txtbkc(4).Text = "" 'So cell' txtc(7).Text = "" txtc(6).Text = "" txtc(5).Text = "" txtc(4).Text = ""
'Xoa Frame lap' 'He so tai' txthst(0).Text = "" txthst(1).Text = "" txthst(2).Text = "" txthst(3).Text = "" 'So thue bao' txtstb(0).Text = "" txtstb(1).Text = "" txtstb(2).Text = "" txtstb(3).Text = "" 'Du tru nhieu' txtdtn(0).Text = "" txtdtn(1).Text = "" txtdtn(2).Text = "" txtdtn(3).Text = "" 'Suy hao cho phep'
txtshcd(0).Text = "" txtshcd(1).Text = "" txtshcd(2).Text = "" txtshcd(3).Text = "" 'Ban kinh cell' txtbkc(0).Text = "" txtbkc(1).Text = "" txtbkc(2).Text = "" txtbkc(3).Text = "" 'So cell' txtc(0).Text = "" txtc(1).Text = "" txtc(2).Text = "" txtc(3).Text = "" 'Xoa tong' txtdlt.Text = "" txtdtt.Text = "" txtctcl.Text = "" txtctl.Text = "" Case "recommand": 'Lay gia tri dung luong' txtdl(0).Text = dla txtdl(1).Text = dlb txtdl(2).Text = dlc txtdl(3).Text = dld 'Lay gia tri vung phu' txtdt(0).Text = dta txtdt(1).Text = dtb txtdt(2).Text = dtc txtdt(3).Text = dtd 'Lay ban kinh va dien tich' txtkqbk(0).Text = bk txtkqdt(0).Text = dt 'Lay mo hinh va vung' Select Case mohinh Case 0: Select Case vung1 Case 0: txtvung.Text = "Thanh pho lon" Case 1: txtvung.Text = "Thanh pho nho va trung binh" Case 2: txtvung.Text = "Ngoai o" Case 3: txtvung.Text = "Nong thon" End Select txtmh.Text = "Hata Okumura" Case 1: Select Case vung1 Case 0: txtvung.Text = "Thanh pho lon"
Case 1: txtvung.Text = "Thanh pho nho va trung binh" End Select txtmh.Text = "Walfisch-Ikegami" End Select Case "result": 'Lay cac gia tri' txthst(11).Text = Round(hst * 0.75, 2) txthst(10).Text = Round(hst * 0.75, 2) txthst(9).Text = Round(hst * 0.75, 2) txthst(8).Text = Round(hst * 0.75, 2) txtkqbk(0).Text = bk txtkqdt(0).Text = dt Select Case mohinh Case 0: Select Case vung1 Case 0: txtvung.Text = "Thanh pho lon" Case 1: txtvung.Text = "Thanh pho nho va trung binh" Case 2: txtvung.Text = "Ngoai o" Case 3: txtvung.Text = "Nong thon" End Select txtmh.Text = "Hata Okumura" Case 1: Select Case vung1 Case 0: txtvung.Text = "Thanh pho lon" Case 1: txtvung.Text = "Thanh pho nho va trung binh" End Select txtmh.Text = "Walfisch-Ikegami" End Select Dim stba!, stbb!, stbc!, stbd! Dim hsta!, hstb!, hstc!, hstd! Dim dtna!, dtnb!, dtnc!, dtnd! Dim shcda!, shcdb!, shcdc!, shcdd! Dim bkca!, bkcb!, bkcc!, bkcd! Dim ca!, cb!, cc!, cd! Dim hstai!, hstbi!, hstci!, hstdi! 'Tinh so thue bao moi dai quat' stba = Round(sothuebao(Val(txtdl(0).Text), celltonga)) stbb = Round(sothuebao(Val(txtdl(1).Text), celltongb)) stbc = Round(sothuebao(Val(txtdl(2).Text), celltongc)) stbd = Round(sothuebao(Val(txtdl(3).Text), celltongd)) 'Tinh he so tai' hsta = hst1(stba) hstb = hst1(stbb) hstc = hst1(stbc) hstd = hst1(stbd)
'Tinh du tru nhieu' dtna = dtni(hsta) dtnb = dtni(hstb) dtnc = dtni(hstc) dtnd = dtni(hstd) 'Tinh suy hao cho phep cuc dai' shcda = shcp(dtna) shcdb = shcp(dtnb) shcdc = shcp(dtnc) shcdd = shcp(dtnd) 'Tinh ban cell' bkca = tinhbksh(mohinh, vung, shcda) bkcb = tinhbksh(mohinh, vung, shcdb) bkcc = tinhbksh(mohinh, vung, shcdc) bkcd = tinhbksh(mohinh, vung, shcdd) 'Hien ket qua' 'Xoa Frame ket qua chua lap' 'He so tai' txthst(7).Text = hsta txthst(6).Text = hstb txthst(5).Text = hstc txthst(4).Text = hstd 'So thue bao' txtstb(7).Text = stba txtstb(6).Text = stbb txtstb(5).Text = stbc txtstb(4).Text = stbd 'Du tru nhieu' txtdtn(7).Text = dtna txtdtn(6).Text = dtnb txtdtn(5).Text = dtnc txtdtn(4).Text = dtnd 'Suy hao cho phep' txtshcd(7).Text = shcda txtshcd(6).Text = shcdb txtshcd(5).Text = shcdc txtshcd(4).Text = shcdd 'Ban kinh cell' txtbkc(7).Text = bk txtbkc(6).Text = bk txtbkc(5).Text = bk txtbkc(4).Text = bk 'So cell' txtc(7).Text = celltonga txtc(6).Text = celltongb txtc(5).Text = celltongc
txtc(4).Text = celltongd txtctcl.Text = Val(txtc(7).Text) + Val(txtc(6).Text) + Val(txtc(5).Text) + Val(txtc(4).Text) 'Xoa Frame lap' 'He so tai' txthst(0).Text = hsta txthst(1).Text = hstb txthst(2).Text = hstc txthst(3).Text = hstd 'So thue bao' txtstb(0).Text = stba txtstb(1).Text = stbb txtstb(2).Text = stbc txtstb(3).Text = stbd 'Du tru nhieu' txtdtn(0).Text = dtna txtdtn(1).Text = dtnb txtdtn(2).Text = dtnc txtdtn(3).Text = dtnd 'Suy hao cho phep' txtshcd(0).Text = shcda txtshcd(1).Text = shcdb txtshcd(2).Text = shcdc txtshcd(3).Text = shcdd 'Ban kinh cell' txtbkc(0).Text = bk txtbkc(1).Text = bk txtbkc(2).Text = bk txtbkc(3).Text = bk 'So cell' txtc(0).Text = celltonga txtc(1).Text = celltongb txtc(2).Text = celltongc txtc(3).Text = celltongd 'Ket qua tong' txtctl.Text = Val(txtc(0).Text) + Val(txtc(1).Text) + Val(txtc(2).Text) + Val(txtc(3).Text) txtdlt.Text = Val(txtdl(0).Text) + Val(txtdl(1).Text) + Val(txtdl(2).Text) + Val(txtdl(3).Text) txtdtt.Text = Val(txtdt(0).Text) + Val(txtdt(1).Text) + Val(txtdt(2).Text) + Val(txtdt(3).Text) Case "back": Unload Me frmmain.Visible = False
frmCell.Show Case "next": frmAbout4.Show Case "home": Unload Me frmmain.Visible = True frmmain.Show End Select End Sub
Private Sub cmdlap_Click() Dim stbal!, stbbl!, stbcl!, stbdl! Dim hstal!, hstbl!, hstcl!, hstdl! Dim dtnal!, dtnbl!, dtncl!, dtndl! Dim shcdal!, shcdbl!, shcdcl!, shcddl! Dim bkcal!, bkcbl!, bkccl!, bkcdl! Dim cal!, cbl!, ccl!, cdl! Dim hstail!, hstbil!, hstcil!, hstdil! Dim ia!, ib!, ic!, id!, iai!, ibi!, ici!, idi! txtmh.Enabled = False txtvung.Enabled = False 'Lay gia tri ban dau cua suy hao cho phep va he so tai' shcdal = Val(txtshcd(0).Text) shcdbl = Val(txtshcd(1).Text) shcdcl = Val(txtshcd(2).Text) shcddl = Val(txtshcd(3).Text) hstal = Val(txthst(0).Text) hstbl = Val(txthst(1).Text) hstcl = Val(txthst(2).Text) hstdl = Val(txthst(3).Text) ia = Val(txthst(11).Text) ib = Val(txthst(10).Text) ic = Val(txthst(9).Text) id = Val(txthst(8).Text) 'Do While ((ia <> hstal) Or (ib <> hstbl) Or (ic <> hstcl) Or (id <> hstdl))' 'Tinh lai ban kinh cell' bkcal = tinhbksh(mohinh, vung, shcdal) bkcbl = tinhbksh(mohinh, vung, shcdbl) bkccl = tinhbksh(mohinh, vung, shcdcl) bkcdl = tinhbksh(mohinh, vung, shcddl) 'Hien thi lai ban kinh' txtbkc(0) = bkcal txtbkc(1) = bkcbl txtbkc(2) = bkccl
txtbkc(3) = bkcdl 'Tinh lai so cell theo ban kinh' cal = Round(Val(txtdt(0).Text) / (2.6 * bkcal ^ 2)) cbl = Round(Val(txtdt(1).Text) / (2.6 * bkcbl ^ 2)) ccl = Round(Val(txtdt(2).Text) / (2.6 * bkccl ^ 2)) cdl = Round(Val(txtdt(3).Text) / (2.6 * bkcdl ^ 2)) 'Hien thi lai so cell' If (cal >= celldla) Then If (cal >= Val(txtc(0).Text)) Then txtc(0).Text = Val(txtc(0).Text) Else txtc(0).Text = cal End If Else txtc(0).Text = celldla End If If (cbl >= celldlb) Then If (cbl >= Val(txtc(1).Text)) Then txtc(1).Text = Val(txtc(1).Text) Else txtc(1).Text = cbl End If Else txtc(1).Text = celldlb End If If (ccl >= celldlc) Then If (ccl >= Val(txtc(2).Text)) Then txtc(2).Text = Val(txtc(2).Text) Else txtc(2).Text = ccl End If Else txtc(2).Text = celldlc End If If (cdl >= celldld) Then If (cdl >= Val(txtc(3).Text)) Then txtc(3).Text = Val(txtc(3).Text) Else txtc(3).Text = cdl End If Else txtc(3).Text = celldld End If txtctl.Text = Val(txtc(0).Text) + Val(txtc(1).Text) + Val(txtc(2).Text) + Val(txtc(3).Text) 'Tinh lai so thue bao' stbal = sothuebao(Val(txtdl(0).Text), Val(txtc(0).Text))
stbbl = sothuebao(Val(txtdl(1).Text), Val(txtc(1).Text)) stbcl = sothuebao(Val(txtdl(2).Text), Val(txtc(2).Text)) stbdl = sothuebao(Val(txtdl(3).Text), Val(txtc(3).Text)) 'Hien thi lai so thue bao' txtstb(0).Text = stbal txtstb(1).Text = stbbl txtstb(2).Text = stbcl txtstb(3).Text = stbdl 'Tinh lai he so tai' hstail = hst1(Val(txtstb(0).Text)) hstbil = hst1(Val(txtstb(1).Text)) hstcil = hst1(Val(txtstb(2).Text)) hstdil = hst1(Val(txtstb(3).Text)) 'Hien thi lai he so tai' txthst(0).Text = hstail txthst(1).Text = hstbil txthst(2).Text = hstcil txthst(3).Text = hstdil 'Tinh lai du tru nhieu' dtnal = dtni(ia) dtnbl = dtni(ib) dtncl = dtni(ic) dtndl = dtni(id) 'dtnal = dtni(hstal)' 'dtnbl = dtni(hstbl) ' 'dtncl = dtni(hstcl) ' 'dtndl = dtni(hstdl)' 'Hien thi lai du tru nhieu' txtdtn(0).Text = dtnal txtdtn(1).Text = dtnbl txtdtn(2).Text = dtncl txtdtn(3).Text = dtndl 'Tinh lai suy hao cho phep' shcdal = shcp(dtnal) shcdbl = shcp(dtnbl) shcdcl = shcp(dtncl) shcddl = shcp(dtndl) 'Hien thi lai suy hao cho phep' txtshcd(0).Text = shcdal txtshcd(1).Text = shcdbl txtshcd(2).Text = shcdcl txtshcd(3).Text = shcddl If (ia = hstail) Then ia = ia
ElseIf (ia > hstail) Then ia = ia - 0.01 Else ia = ia + 0.01 End If If (ib < hstbil) Then ib = ib + 0.01 ElseIf (ib > hstbil) Then ib = ib - 0.01 Else ib = ib End If If (ic < hstcil) Then ic = ic + 0.01 ElseIf (ic > hstcil) Then ic = ic - 0.01 Else ic = ic End If If (id < hstdil) Then id = id + 0.01 ElseIf (id > hstdil) Then id = id - 0.01 Else id = id End If txthst(11).Text = ia txthst(10).Text = ib txthst(9).Text = ic txthst(8).Text = id 'Loop' End Sub Private Sub cmdlap1_Click() Dim stbal!, stbbl!, stbcl!, stbdl! Dim hstal!, hstbl!, hstcl!, hstdl! Dim dtnal!, dtnbl!, dtncl!, dtndl! Dim shcdal!, shcdbl!, shcdcl!, shcddl! Dim bkcal!, bkcbl!, bkccl!, bkcdl! Dim cal!, cbl!, ccl!, cdl! Dim hstail!, hstbil!, hstcil!, hstdil! Dim ia!, ib!, ic!, id!, iai!, ibi!, ici!, idi! txtmh.Enabled = False txtvung.Enabled = False 'Lay gia tri ban dau cua suy hao cho phep va he so tai' shcdal = Val(txtshcd(0).Text)
shcdbl = Val(txtshcd(1).Text) shcdcl = Val(txtshcd(2).Text) shcddl = Val(txtshcd(3).Text) hstal = Val(txthst(0).Text) hstbl = Val(txthst(1).Text) hstcl = Val(txthst(2).Text) hstdl = Val(txthst(3).Text) ia = Val(txthst(11).Text) ib = Val(txthst(10).Text) ic = Val(txthst(9).Text) id = Val(txthst(8).Text) 'Tao dong ho cat cho chuot Screen.MousePointer = vbHourglass 'Do While ((ia <> hstail) Or (ib <> hstbil) Or (ic <> hstcil) Or (id <> hstdil))' For i = 0 To 9000 'Tinh lai ban kinh cell' bkcal = tinhbksh(mohinh, vung, shcdal) bkcbl = tinhbksh(mohinh, vung, shcdbl) bkccl = tinhbksh(mohinh, vung, shcdcl) bkcdl = tinhbksh(mohinh, vung, shcddl) 'Hien thi lai ban kinh' txtbkc(0) = bkcal txtbkc(1) = bkcbl txtbkc(2) = bkccl txtbkc(3) = bkcdl 'Tinh lai so cell theo ban kinh' cal = Round(TinhCdt(Val(txtdt(0).Text), bkcal)) 'cal = Round(Val(txtdt(0).Text) / (2.6 * bkcal ^ 2)) cbl = Round(TinhCdt(Val(txtdt(1).Text), bkcbl)) 'cbl = Round(Val(txtdt(1).Text) / (2.6 * bkcbl ^ 2)) ccl = Round(TinhCdt(Val(txtdt(2).Text), bkccl)) 'ccl = Round(Val(txtdt(2).Text) / (2.6 * bkccl ^ 2)) cdl = Round(TinhCdt(Val(txtdt(3).Text), bkcdl)) 'cdl = Round(Val(txtdt(3).Text) / (2.6 * bkcdl ^ 2)) 'Hien thi lai so cell' If (cal >= celldla) Then 'If (cal >= Val(txtc(0).Text)) Then 'txtc(0).Text = Val(txtc(0).Text) 'Else txtc(0).Text = cal 'End If Else txtc(0).Text = celldla End If If (cbl >= celldlb) Then 'If (cbl >= Val(txtc(1).Text)) Then
'txtc(1).Text = Val(txtc(1).Text) 'Else txtc(1).Text = cbl 'End If Else txtc(1).Text = celldlb End If If (ccl >= celldlc) Then 'If (ccl >= Val(txtc(2).Text)) Then ' txtc(2).Text = Val(txtc(2).Text) 'Else txtc(2).Text = ccl 'End If Else txtc(2).Text = celldlc End If If (cdl >= celldld) Then 'If (cdl >= Val(txtc(3).Text)) Then ' txtc(3).Text = Val(txtc(3).Text) 'Else txtc(3).Text = cdl 'End If Else txtc(3).Text = celldld End If txtctl.Text = Val(txtc(0).Text) + Val(txtc(1).Text) + Val(txtc(2).Text) + Val(txtc(3).Text) 'Tinh lai so thue bao' stbal = sothuebao(Val(txtdl(0).Text), Val(txtc(0).Text)) stbbl = sothuebao(Val(txtdl(1).Text), Val(txtc(1).Text)) stbcl = sothuebao(Val(txtdl(2).Text), Val(txtc(2).Text)) stbdl = sothuebao(Val(txtdl(3).Text), Val(txtc(3).Text)) 'Hien thi lai so thue bao' txtstb(0).Text = stbal txtstb(1).Text = stbbl txtstb(2).Text = stbcl txtstb(3).Text = stbdl 'Tinh lai he so tai' hstail = hst1(Val(txtstb(0).Text)) hstbil = hst1(Val(txtstb(1).Text)) hstcil = hst1(Val(txtstb(2).Text)) hstdil = hst1(Val(txtstb(3).Text)) 'Hien thi lai he so tai' txthst(0).Text = hstail txthst(1).Text = hstbil txthst(2).Text = hstcil txthst(3).Text = hstdil
'Tinh lai du tru nhieu' dtnal = dtni(ia) dtnbl = dtni(ib) dtncl = dtni(ic) dtndl = dtni(id) 'dtnal = dtni(hstal)' 'dtnbl = dtni(hstbl) ' 'dtncl = dtni(hstcl) ' 'dtndl = dtni(hstdl)' 'Hien thi lai du tru nhieu' txtdtn(0).Text = dtnal txtdtn(1).Text = dtnbl txtdtn(2).Text = dtncl txtdtn(3).Text = dtndl 'Tinh lai suy hao cho phep' shcdal = shcp(dtnal) shcdbl = shcp(dtnbl) shcdcl = shcp(dtncl) shcddl = shcp(dtndl) 'Hien thi lai suy hao cho phep' txtshcd(0).Text = shcdal txtshcd(1).Text = shcdbl txtshcd(2).Text = shcdcl txtshcd(3).Text = shcddl If (ia = hstail) Then ia = ia ElseIf (ia > hstail) Then ia = ia - 0.01 Else ia = ia + 0.01 End If If (ib < hstbil) Then ib = ib + 0.01 ElseIf (ib > hstbil) Then ib = ib - 0.01 Else ib = ib End If If (ic < hstcil) Then ic = ic + 0.01 ElseIf (ic > hstcil) Then ic = ic - 0.01 Else ic = ic
End If If (id < hstdil) Then id = id + 0.01 ElseIf (id > hstdil) Then id = id - 0.01 Else id = id End If txthst(11).Text = ia txthst(10).Text = ib txthst(9).Text = ic txthst(8).Text = id Next i 'Loop' Screen.MousePointer = vbDefaut End Sub
CODE MODULES: Khai bin: Option Explicit 'tinh ban kinh theo suy hao' Global Freq!, docaoMS!, docaoBS!, Gocden!, b!, docaoNha!, dorongPho! Global mohinh!, vung! Global hst!, dtn!, dlcd! Global celldla!, celldlb!, celldlc!, celldld!, celldta!, celldtb!, celldtc!, celldtd! Global shcd! Global celltonga!, celltongb!, celltongc!, celltongd! Global dla!, dlb!, dlc!, dld!, dta!, dtb!, dtc!, dtd! Global bk! Global v!, f!, g! 'bien suy hao cho phep' Global Ec!, Gb!, R!, Lc!, Eb!, No!, Pm!, Ltx!, Lct!, Fb!, w!, dt! 'Chi doc textbox Global Const WM_USER = &H400 Global Const EM_SETREADONLY = (WM_USER + 31) Global kiemtra! Chng trnh con: Option Explicit Function shcp(dtts!)
shcp = Round(Pm - No - Fb - Eb - 10 * log10(R) + Gb - Lc - Ec - Lct - Ltx - dtts + 10 * log10(w / R), 2) End Function Function log10(a!) log10 = Log(a) / Log(10) End Function Function tinhbksh(mohinhts!, vungts!, shts!) Dim RCell!, kf!, Lo!, Lbsh!, ka!, kd!, Lp!, Lf!, Lvc!, hesohieuchinh! Select Case mohinhts Case 0: Select Case vungts Case 0: If Freq > 400 Then hesohieuchinh = 3.2 * (log10(11.75 * docaoMS)) ^ 2 - 4.97 Else hesohieuchinh = 8.29 * (log10(1.54 * docaoMS)) ^ 2 - 1.1 End If RCell = (shts - 69.55 - 26.16 * log10(Freq) + 13.82 * log10(docaoBS) + hesohieuchinh) / (44.9 - 6.55 * log10(docaoBS)) Case 1: hesohieuchinh = docaoMS * (1.11 * log10(Freq) - 0.7) - 1.56 * log10(Freq) + 0.8 RCell = (shts - 69.55 - 26.16 * log10(Freq) + 13.82 * log10(docaoBS) + hesohieuchinh) / (44.9 - 6.55 * log10(docaoBS)) Case 2: hesohieuchinh = docaoMS * (1.11 * log10(Freq) - 0.7) - 1.56 * log10(Freq) + 0.8 RCell = (shts - 69.55 - 26.16 * log10(Freq) + 13.82 * log10(docaoBS) + hesohieuchinh + 2 * log10((Freq / 28) ^ 2) - 5.4) / (44.9 - 6.55 * log10(docaoBS)) Case 3: hesohieuchinh = docaoMS * (1.11 * log10(Freq) - 0.7) - 1.56 * log10(Freq) + 0.8 RCell = (shts - 69.55 - 26.16 * log10(Freq) + 13.82 * log10(docaoBS) + hesohieuchinh + 8) / (44.9 - 6.55 * log10(docaoBS)) End Select Case 1: Select Case vungts Case 0: kf = 4 + 1.5 * (Freq / 925 - 1) Case 1: kf = 4 + 0.7 * Freq / 925 - 0.7 End Select If ((Gocden >= 0) And (Gocden <= 35)) Then Lo = -9.646 End If If ((Gocden > 35) And (Gocden <= 55)) Then Lo = 2.5 + 0.075 * (Gocden - 35) End If If ((Gocden > 55) And (Gocden <= 90)) Then
Lo = 4 - 0.114 * (Gocden - 55) End If If (docaoBS >= docaoNha) Then Lbsh = -18 * log10(11) + (docaoBS - docaoNha) ka = 54 kd = 18 - 15 * (docaoBS - docaoNha) / (docaoNha - docaoMS) End If If (docaoBS < docaoNha) Then Lbsh = 0 ka = 54 - 0.8 * docaoBS kd = 18 End If Lp = Lo + 10 * log10(Freq) - 10 * log10(dorongPho) - 16.7 + 20 * log10(docaoNha - docaoMS) Lf = 32.4 + 20 * log10(Freq) Lvc = Lbsh + ka + kf * log10(Freq) - 9 * log10(b) RCell = (shts - Lf - Lvc - Lp) / (20 + kd) End Select tinhbksh = Round(10 ^ RCell, 2) End Function Function dtni(hst1!) If (hst1 >= 1) Then dtni = 20 Else dtni = Round((-10) * (log10(1 - hst1)), 2) End If End Function Function hst1(stb!) hst1 = Round((Eb * R * stb * v * (1 + f)) / w, 2) End Function Function sothuebao(dungluong!, socell!) sothuebao = Round(dungluong / socell * 65 / 3600) End Function Function TinhCdt(dtt!, bkc!) TinhCdt = Round(dtt / 2.6 / bkc ^ 2) End Function Function TinhCdl(dlt!) TinhCdl = Round(dlt * 65 / 3600 * 1.38 * 1.4 / 2.4 / dlcd) End Function
Declare Function HtmlHelp Lib "HHCtrl.ocx" Alias "HtmlHelpA" _ (ByVal hwndCaller As Long, ByVal pszFile As String, _ ByVal uCommand As Long, dwData As Any) As Long Public Declare Function GetDesktopWindow Lib "user32" () As Long Function ErlangB1(n!) Dim ErlangB! Select Case n Case Is = 1: ErlangB = 0.02 Case 2: ErlangB = 0.222 Case 3: ErlangB = 0.602 Case 4: ErlangB = 1.092 Case 5: ErlangB = 1.657 Case 6: ErlangB = 2.276 Case 7: ErlangB = 2.935 Case 8: ErlangB = 3.627 Case 9: ErlangB = 4.345 Case 10: ErlangB = 5.084 Case 11: ErlangB = 5.842 Case 12: ErlangB = 6.615 Case 13: ErlangB = 7.402 Case 14: ErlangB = 8.2 Case 15: ErlangB = 9.01 Case 16: ErlangB = 9.828 Case 17: ErlangB = 10.656 Case 18: ErlangB = 11.491 Case 19: ErlangB = 12.333
Case 20: ErlangB = 13.182 Case 21: ErlangB = 14.036 Case 22: ErlangB = 14.896 Case 23: ErlangB = 15.761 Case 24: ErlangB = 16.631 Case 25: ErlangB = 17.505 Case 26: ErlangB = 18.383 Case 27: ErlangB = 19.256 Case 28: ErlangB = 20.15 Case 29: ErlangB = 21.039 Case 30: ErlangB = 21.932 Case 31: ErlangB = 22.827 Case 32: ErlangB = 23.725 Case 33: ErlangB = 24.626 Case 34: ErlangB = 25.529 Case 35: ErlangB = 26.435 Case 36: ErlangB = 27.343 Case 37: ErlangB = 28.254 Case 38: ErlangB = 29.166 Case 39: ErlangB = 30.081 Case 40: ErlangB = 30.997 Case 41: ErlangB = 31.916 Case 42: ErlangB = 32.836
Case 43: ErlangB = 33.758 Case 44: ErlangB = 34.682 Case 45: ErlangB = 35.607 Case 46: ErlangB = 36.534 Case 47: ErlangB = 37.462 Case 48: ErlangB = 38.392 Case 49: ErlangB = 39.323 Case 50: ErlangB = 40.255 Case 51: ErlangB = 41.189 Case 52: ErlangB = 42.124 Case 53: ErlangB = 43.06 Case 54: ErlangB = 43.997 Case 55: ErlangB = 44.936 Case 56: ErlangB = 45.875 Case 57: ErlangB = 46.816 Case 58: ErlangB = 47.758 Case 59: ErlangB = 48.7 Case 60: ErlangB = 49.644 Case 61: ErlangB = 50.589 Case 62: ErlangB = 51.534 Case 63: ErlangB = 52.481 Case 64: ErlangB = 53.428 Case 65: ErlangB = 54.376
Case 66: ErlangB = 55.325 Case 67: ErlangB = 56.275 Case 68: ErlangB = 57.226 Case 69: ErlangB = 58.177 Case 70: ErlangB = 59.129 Case 71: ErlangB = 60.082 Case 72: ErlangB = 61.036 Case 73: ErlangB = 61.99 Case 74: ErlangB = 62.945 Case 75: ErlangB = 63.9 Case 76: ErlangB = 64.857 Case 77: ErlangB = 65.814 Case 78: ErlangB = 66.771 Case 79: ErlangB = 67.729 Case 80: ErlangB = 68.688 Case 81: ErlangB = 69.647 Case 82: ErlangB = 70.607 Case 83: ErlangB = 71.568 Case 84: ErlangB = 72.529 Case 85: ErlangB = 73.49 Case 86: ErlangB = 74.452 Case 87: ErlangB = 75.514 Case 88: ErlangB = 76.378
Case 89: ErlangB = 77.342 Case 90: ErlangB = 78.306 Case 91: ErlangB = 79.271 Case 92: ErlangB = 80.236 Case 93: ErlangB = 81.201 Case 94: ErlangB = 82.167 Case 95: ErlangB = 83.133 Case 96: ErlangB = 84.1 Case 97: ErlangB = 85.068 Case 98: ErlangB = 86.035 Case 99: ErlangB = 87.003 Case 100: ErlangB = 87.972 End Select ErlangB1 = ErlangB End Function