Code:Private Sub mnuOpen_Click() On Error GoTo errTrap mnuCoordinateList(1).Checked = True mnuCoordinateList(2).Checked = False With CommonDialog1 .CancelError = True .Filter = "dKart ACSII files (*.daf)|*.daf|" .ShowOpen End With strFileNewName1 = (Left(CommonDialog1.FileName, InStr(1, CommonDialog1.FileName, "\DAF")) & "Map\") strFileNewName2 = (Mid(CommonDialog1.FileName, InStr(1, CommonDialog1.FileName, "MY"), 8) & ".bmp") strFileNewName3 = strFileNewName1 & strFileNewName2 strFileNewName4 = (Left(CommonDialog1.FileName, InStr(1, CommonDialog1.FileName, "\DAF")) & "Setting\Daf.txt") strFileNewName5 = (Left(CommonDialog1.FileName, InStr(1, CommonDialog1.FileName, "\DAF")) & "Setting\Output.txt") Picture1.Picture = LoadPicture(strFileNewName3) Call Convert Call ENCExtract If mnuCoordinateList(1).Checked = True Then Call DecimalDegrees ElseIf mnuCoordinateList(2).Checked = True Then Call DDtoDMS End If blnOkToMove = True 'add the file just opened to our MRU list Call WriteMRUList(CommonDialog1.FileName) Exit Sub errTrap: 'cancel was hit, so dont do anything End Subwhen i put mnuOpen and DDtoDMS at the same form, it can work. But , when i moved the DDtoDMs to a module.it came out an error "sub or function not defined"and highlight the code call DDtoDMS.how to improve my code if i want DDtoDMS in module.Code:Private Sub DDtoDMS() Dim sLines() As String Dim Degrees1 As Variant, Degrees2 As Variant, Degrees3 As Variant, Degrees4 As Variant Dim Minutes1 As Variant, Minutes2 As Variant, Minutes3 As Variant, Minutes4 As Variant Dim seconds1 As Variant, seconds2 As Variant, Seconds3 As Variant, Seconds4 As Variant Dim A As Variant Dim B As Variant On Error GoTo errTrap: strFileNewName4 = (Left(CommonDialog1.FileName, InStr(1, CommonDialog1.FileName, "\DAF")) & "Setting\Daf.txt") Open strFileNewName4 For Input As #1 sLines = Split(Input(LOF(1), #1), vbCrLf) Close #1 Degrees1 = Int(sLines(1)) Minutes1 = (sLines(1) - Degrees1) * 60 seconds1 = Format(((Minutes1 - Int(Minutes1)) * 60), "0") Label1.Caption = " " & Degrees1 & "° " & Int(Minutes1) & "' " _ & seconds1 + Chr(34) Degrees2 = Int(sLines(2)) Minutes2 = (sLines(2) - Degrees2) * 60 seconds2 = Format(((Minutes2 - Int(Minutes2)) * 60), "0") Label2.Caption = " " & Degrees2 & "° " & Int(Minutes2) & "' " _ & seconds2 + Chr(34) Degrees3 = Int(sLines(3)) Minutes3 = (sLines(3) - Degrees3) * 60 Seconds3 = Format(((Minutes3 - Int(Minutes3)) * 60), "0") Label3.Caption = " " & Degrees3 & "° " & Int(Minutes3) & "' " _ & Seconds3 + Chr(34) Degrees4 = Int(sLines(4)) Minutes4 = (sLines(4) - Degrees4) * 60 Seconds4 = Format(((Minutes4 - Int(Minutes4)) * 60), "0") Label4.Caption = " " & Degrees4 & "° " & Int(Minutes4) & "' " _ & Seconds4 + Chr(34) errTrap: End Sub




Reply With Quote