[Chú ý] Thắc mắc về lập trình Basic4Android
Moderator: tummosoft
Re: [Chú ý] Thắc mắc về lập trình Basic4Android
em cám ơn anh đã giúp em.trước em làm thấy báo lỗi về khai báo mảng rồi linh tinh các thứ khác mãi không thể làm nổi.em cám ơn anh đã tận tình giúp đỡ em.
e đã viết lại xong nhưng bị 1 cái là kết quả bị sai so với file exel mà em dựa vào đó để làm. em sẽ dò lại các tính toán của em xem đã chuẩn chưa vì dấu ^ trong b4a không có đúng k a
e đã viết lại xong nhưng bị 1 cái là kết quả bị sai so với file exel mà em dựa vào đó để làm. em sẽ dò lại các tính toán của em xem đã chuẩn chưa vì dấu ^ trong b4a không có đúng k a
Re: [Chú ý] Thắc mắc về lập trình Basic4Android
anh xem giup e cai marc1 e lam the nay da dung chua a. vi khi kết quả M em xem nó lại bằng 0,nên kết quả nó bị sai.
trong khi trong VB em viết thế này đã chạy đúng rồi mà
em cam on anh a
Code: Select all
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this modul
Dim Nort,East As Double
Private lon As EditText
Private lat As EditText
Private TINH As Button
Private Label1 As Label
Private Label2 As Label
Private Label3 As Label
Private Button1 As Button
Private Label4 As Label
Private Label5 As Label
Private EditText1 As EditText
Private EditText2 As EditText
Private Label7 As Label
Private Label6 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
Dim Nort,East As Double
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_click
'Project Latitude and longitude to Transverse Mercator eastings.
'Input: - _
'North and East are positive direction
'constants specific to WGS84
Dim phi,lam As Double
phi = lat.Text
lam = lon.text
Dim a, b, e0, f0, PHI0 As Double
a = 6378137
b = 6356752.3141
e0 = 500000
f0 = 0.9996
PHI0 = 0
'Calculate LAM0 of the UTM zone which the user input Longitude is in
Dim PreZNum As Double
Dim ZNum As Int
Dim LAM0 As Double
PreZNum = (180 + lam) / 6 + 1
ZNum =(PreZNum)
LAM0 = -(183 - 6 * ZNum)
'Convert angle measures to radians
Dim pi,radphi,radlam,radphi0,radlam0,af0,bf0,e2,n,nu,rho,eta2,p,iv,v,vi As Double
pi = 3.14159265358979
radphi = phi * (pi / 180)
radlam = lam * (pi / 180)
radphi0 = PHI0 * (pi / 180)
radlam0 = LAM0 * (pi / 180)
af0 = a * f0
bf0 = b * f0
e2 = ((af0*af0) - (bf0*bf0)) / (af0*af0)
n = (af0 - bf0) / (af0 + bf0)
nu = af0 / Sqrt(1 - (e2 * ((Sin(radphi)*Sin(radphi)))))
rho = (nu * (1 - e2)) / (1 - (e2 * (Sin(radphi)*Sin(radphi))))
eta2 = (nu / rho) - 1
p = radlam - radlam0
iv = nu * (Cos(radphi))
v = (nu / 6) * ((Cos(radphi)*Cos(radphi)*Cos(radphi))) * ((nu / rho) - ((Tan(radphi)*Tan(radphi))))
vi = (nu / 120) * (Cos(radphi)*Cos(radphi)*Cos(radphi)*Cos(radphi)*Cos(radphi)*Cos(radphi)) * (5 - (18 * ((Tan(radphi)*Tan(radphi)))) + ((Tan(radphi)*Tan(radphi)*Tan(radphi)*Tan(radphi)*Tan(radphi))) + (14 * eta2) - (58 * ((Tan(radphi)*Tan(radphi))) * eta2))
East = e0 + (p * iv) + ((p*p*p) * v) + ((p*p*p*p*p) * vi)
Label1.Text = East
'Project Latitude and longitude to Transverse Mercator northings
'Input: - _
Dim phi,lam As Double
phi = lat.Text
lam = lon.text
'REQUIRES THE "Marc1" FUNCTION
'constants specific to WGS84
Dim a, b, e0, f0, n0, PHI0 As Double
a = 6378137
b = 6356752.3141
e0 = 500000
f0 = 0.9996
PHI0 = 0
n0 = 0
'Calculate LAM0 of the UTM zone which the user input Longitude is in
Dim PreZNum As Double
Dim ZNum As Int
Dim LAM0 As Double
PreZNum = (180 + lam) / 6 + 1
ZNum = (PreZNum)
LAM0 = -(183 - 6 * ZNum)
'Convert angle measures to radians
Dim pi,radphi,radlam,radphi0,radlam0,af0,bf0,e2,n,nu,rho,eta2,p,m,i,ii,iii,iiia As Double
pi = 3.14159265358979
radphi = phi * (pi / 180)
radlam = lam * (pi / 180)
radphi0 = PHI0 * (pi / 180)
radlam0 = LAM0 * (pi / 180)
af0 = a * f0
bf0 = b * f0
e2 = ((af0*af0) - (bf0*bf0)) / (af0*af0)
n = (af0 - bf0) / (af0 + bf0)
nu = af0 / Sqrt(1 - (e2 * ((Sin(radphi)*Sin(radphi)))))
rho = (nu * (1 - e2)) / (1 - (e2 * (Sin(radphi)*Sin(radphi))))
eta2 = (nu / rho) - 1
p = radlam - radlam0
m = marc1(bf0, n, radphi0, radphi)
i = m + n0
ii = (nu / 2) * (Sin(radphi)) * (Cos(radphi))
iii = ((nu / 24) * (Sin(radphi)) * ((Cos(radphi)*Cos(radphi)*Cos(radphi)))) * (5 - ((Tan(radphi)*Tan(radphi))) + (9 * eta2))
iiia = ((nu / 720) * (Sin(radphi)) * ((Cos(radphi)*Cos(radphi)*Cos(radphi)*Cos(radphi)*Cos(radphi)))) * (61 - (58 * ((Tan(radphi)*Tan(radphi)))) + ((Tan(radphi)*Tan(radphi)*Tan(radphi)*Tan(radphi))))
Nort = i + ((p*p) * ii) + ((p*p*p*p) * iii) + ((p*p*p*p*p*p) * iiia)
Label2.Text=Nort
'cai nay ve mui chieu
Dim PreZNum,UTMZone As Double
Dim ZNum As Int
Dim LAM0 As Double
PreZNum = (180 + lam) / 6 + 1
ZNum = PreZNum
UTMZone = ZNum
Label3.Text = UTMZone
End Sub
Public Sub marc1(bf0 As Int , n As Int, phi0 As Int, phi As Int)
Return bf0 * ((1 + n + ((5 / 4) * (n*n)) + ((5 / 4) * (n*n*n))) * (phi - phi0)) -(((3 * n) + (3 * (n*n)) + ((21 / 8) * (n*n*n))) * (Sin(phi - phi0)) * (Cos(phi + phi0))) +((((15 / 8) * (n*n)) + ((15 / 8) * (n*n*n))) * (Sin(2 * (phi - phi0))) * (Cos(2 * (phi + phi0)))) -(((35 / 24) * (n*n*n)) * (Sin(3 * (phi - phi0))) * (Cos(3 * (phi + phi0))))
End Sub
Code: Select all
Private Function ZoneChooser(Longitude)
'Choose the UTM zone number according to user input decimal Longitude
'East is positive direction
Dim PreZNum As Double
PreZNum = (180 + Longitude) / 6 + 1
ZoneChooser = Int(PreZNum)
End Function
Private Function Marc1(bf0, n, PHI0, phi)
Marc1 = bf0 * (((1 + n + ((5 / 4) * (n ^ 2)) + ((5 / 4) * (n ^ 3))) * (phi - PHI0)) _
- (((3 * n) + (3 * (n ^ 2)) + ((21 / 8) * (n ^ 3))) * (Sin(phi - PHI0)) * (Cos(phi + PHI0))) _
+ ((((15 / 8) * (n ^ 2)) + ((15 / 8) * (n ^ 3))) * (Sin(2 * (phi - PHI0))) * (Cos(2 * (phi + PHI0)))) _
- (((35 / 24) * (n ^ 3)) * (Sin(3 * (phi - PHI0))) * (Cos(3 * (phi + PHI0)))))
End Function
Private Sub Command1_Click()
Dim a, b, e0, f0, PHI0 As Double
a = 6378137
b = 6356752.3141
e0 = 500000
f0 = 0.9996
PHI0 = 0
'Calculate LAM0 of the UTM zone which the user input Longitude is in
Dim PreZNum As Double
Dim ZNum As Integer
Dim LAM0 As Double
PreZNum = (180 + lam) / 6 + 1
ZNum = Int(PreZNum)
LAM0 = -(183 - 6 * ZNum)
'Convert angle measures to radians
PI = 3.14159265358979
RadPHI = phi * (PI / 180)
RadLAM = lam * (PI / 180)
RadPHI0 = PHI0 * (PI / 180)
RadLAM0 = LAM0 * (PI / 180)
af0 = a * f0
bf0 = b * f0
e2 = ((af0 ^ 2) - (bf0 ^ 2)) / (af0 ^ 2)
n = (af0 - bf0) / (af0 + bf0)
nu = af0 / (Sqr(1 - (e2 * ((Sin(RadPHI)) ^ 2))))
rho = (nu * (1 - e2)) / (1 - (e2 * (Sin(RadPHI)) ^ 2))
eta2 = (nu / rho) - 1
p = RadLAM - RadLAM0
IV = nu * (Cos(RadPHI))
V = (nu / 6) * ((Cos(RadPHI)) ^ 3) * ((nu / rho) - ((Tan(RadPHI) ^ 2)))
VI = (nu / 120) * ((Cos(RadPHI)) ^ 5) * (5 - (18 * ((Tan(RadPHI)) ^ 2)) + ((Tan(RadPHI)) ^ 4) + (14 * eta2) - (58 * ((Tan(RadPHI)) ^ 2) * eta2))
Label1.Caption = e0 + (p * IV) + ((p ^ 3) * V) + ((p ^ 5) * VI)
'Project Latitude and longitude to Transverse Mercator northings
'Input: - _
Latitude (PHI) and Longitude (LAM) in decimal degrees; _
ellipsoid axis dimensions (a & b) in meters; _
eastings (e0) and northings (n0) of false origin in meters; _
central meridian scale factor (f0); _
latitude (PHI0) and longitude (LAM0) of false origin in decimal degrees.
'REQUIRES THE "Marc1" FUNCTION
'constants specific to WGS84
a = 6378137
b = 6356752.3141
e0 = 500000
f0 = 0.9996
PHI0 = 0
n0 = 0
'Calculate LAM0 of the UTM zone which the user input Longitude is in
PreZNum = (180 + lam) / 6 + 1
ZNum = Int(PreZNum)
LAM0 = -(183 - 6 * ZNum)
'Convert angle measures to radians
PI = 3.14159265358979
RadPHI = phi * (PI / 180)
RadLAM = lam * (PI / 180)
RadPHI0 = PHI0 * (PI / 180)
RadLAM0 = LAM0 * (PI / 180)
af0 = a * f0
bf0 = b * f0
e2 = ((af0 ^ 2) - (bf0 ^ 2)) / (af0 ^ 2)
n = (af0 - bf0) / (af0 + bf0)
nu = af0 / (Sqr(1 - (e2 * ((Sin(RadPHI)) ^ 2))))
rho = (nu * (1 - e2)) / (1 - (e2 * (Sin(RadPHI)) ^ 2))
eta2 = (nu / rho) - 1
p = RadLAM - RadLAM0
m = Marc1(bf0, n, RadPHI0, RadPHI)
i = m + n0
ii = (nu / 2) * (Sin(RadPHI)) * (Cos(RadPHI))
iii = ((nu / 24) * (Sin(RadPHI)) * ((Cos(RadPHI)) ^ 3)) * (5 - ((Tan(RadPHI)) ^ 2) + (9 * eta2))
iiia = ((nu / 720) * (Sin(RadPHI)) * ((Cos(RadPHI)) ^ 5)) * (61 - (58 * ((Tan(RadPHI)) ^ 2)) + ((Tan(RadPHI)) ^ 4))
Label2.Caption = i + ((p ^ 2) * ii) + ((p ^ 4) * iii) + ((p ^ 6) * iiia)
End Sub
- tummosoft
- Điều hành viên
- Posts: 334
- Joined: Mon 19/05/2014 2:23 pm
- Has thanked: 7 times
- Been thanked: 61 times
- Contact:
Re: [Chú ý] Thắc mắc về lập trình Basic4Android
Hướng dẫn và code tạo shortcut ứng dụng lên màn hình chính
http://www.b4x.com/android/forum/thread ... ion.11444/
http://www.b4x.com/android/forum/thread ... ion.11444/


https://www.tummosoftware.com
- minhhath
- Thành viên năng nổ
- Posts: 78
- Joined: Sun 17/01/2010 3:24 pm
- Location: p5,Tỉnh Cà Mau
- Has thanked: 8 times
- Contact:
Re: [Chú ý] Thắc mắc về lập trình Basic4Android
Mình cũng có từng học qua VB.net và C# vậy mình tìm hiểu về Basic4Android thì phải bắt đầu căn bản từ đâu bạn có thể cho mình tài liệu hay ebook để mình tham khảo thêm được không
thanks chủ thớt nhiều

thanks chủ thớt nhiều



Trên đời này không có con đường cùng,mà chỉ có những ranh giới,điều quan trọng là có đủ sức mạnh và nghị lực để vượt qua những ranh giới đó hay không
- tummosoft
- Điều hành viên
- Posts: 334
- Joined: Mon 19/05/2014 2:23 pm
- Has thanked: 7 times
- Been thanked: 61 times
- Contact:
Re: [Chú ý] Thắc mắc về lập trình Basic4Android
Hiện B4A không có tài liệu bằng tiếng Việt. Nếu bạn muốn học thì trước hết xem các video tại đây: viewtopic.php?f=70&t=29348minhhath wrote:Mình cũng có từng học qua VB.net và C# vậy mình tìm hiểu về Basic4Android thì phải bắt đầu căn bản từ đâu bạn có thể cho mình tài liệu hay ebook để mình tham khảo thêm được không
thanks chủ thớt nhiều![]()
![]()
Kế tiếp thì xem các bài mình đánh dấu theo thứ tự từ thấp đến cao. Nếu đọc thấy khó hiểu thì xem các video bổ sung rồi thực hành theo.


https://www.tummosoftware.com
Re: [Chú ý] Thắc mắc về lập trình Basic4Android
http://tinhtuoi.zz.mu/New%20Bitmap%20Image.bmp
ai xem dùm em lỗi gì ạ
ai xem dùm em lỗi gì ạ
Lỗi b4a brige
Có ai biết làm thế nào để có thể kết nối pc với b4a brige 2.36 không ạ? Ai biết thì mong giúp đỡ.help
Re: [Chú ý] Thắc mắc về lập trình Basic4Android
Hi all!
Mình đang cần mấy thư viện này, bạn nào có cho mình xin với nhé (không download trong forum B4x được).
- Dialogs
- RandomAccessFile
- ScrollView2D
Cảm ơn nhiều!
Mình đang cần mấy thư viện này, bạn nào có cho mình xin với nhé (không download trong forum B4x được).
- Dialogs
- RandomAccessFile
- ScrollView2D
Cảm ơn nhiều!
Re: [Chú ý] Thắc mắc về lập trình Basic4Android
Basic4Android là gì thế ạ? Thấy mọi người viết hay quá mà đang không hiểu gì