我正在用eye4software製作一個簡單的座標轉換器。以下鏈接爲轉換器提供了所需的Visual Basic 6代碼。座標轉換
http://www.eye4software.com/products/gpstoolkit/source/vb/datumtransformation/
我按照根據鏈接所提供的資料說的過程。
Private Sub Form1_Load()
Private objProjection As GpsProjection
Private objDatumSrc As GpsDatumParameters
Private objDatumDst As GpsDatumParameters
Set objProjection = CreateObject("Eye4Software.GpsProjection")
Set objDatumSrc = CreateObject("Eye4Software.GpsDatumParameters")
Set objDatumDst = CreateObject("Eye4Software.GpsDatumParameters")
End Sub
Option Explicit
Private objProjection As GpsProjection
Private objDatumSrc As GpsDatumParameters
Private objDatumDst As GpsDatumParameters
Private Sub CommandTranslate_Click()
' Set Source Datum (WGS84)
' The ID for WGS84 is 4326, see 'http://www.eye4software.com/resources/datums' for a full list of supported datums
' To convert from another datum, just change the code below (EPSG code)
objDatumSrc.LoadFromId (4326)
' Set Destination Datum (NAD27)
' The ID for NAD27 is 4267, see 'http://www.eye4software.com/resources/datums' for a full list of supported datums
' To convert to another datum, just change the code below (EPSG code)
objDatumDst.LoadFromId (4267)
' Set Source coordinates
objProjection.Latitude = CDbl(Textlat1.Text)
objProjection.Longitude = CDbl(Textlon1.Text)
' Perform the datum transformation
objProjection.TransformDatum objDatumSrc, objDatumDst
' Display the result
Textlat2.Text = objProjection.Latitude
Textlon2.Text = objProjection.Longitude
End Sub
但我得到一個運行時錯誤此代碼(objDatumSrc.LoadFromId(4326))說所需的對象。由於我是初學者,我無法解決這個問題。請幫幫我。
小問題,但[不要在程序參數中放置括號](http://hashvb.earlsoft.co.uk/Brackets_around_procedure_parameters)。這可能不是問題的原因,但它會在某些時候咬你(同樣的錯誤) – Deanna