borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (daily function)Next Topic (Using vb to read data fomr afile an dinput data into excel to change cell value) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : excel vb project created in 2000 not working correctly in 2002
Poster Message
chcarlill
Level: Trainee

Registered: 07-04-2009
Posts: 1

Ads by Lake Quincy Media
icon excel vb project created in 2000 not working correctly in 2002

This project was developed in excel 2000 and I am trying to use it in 2002 but am getting a error 13 type mismatch.  What can I do to correct this.  Here is the code.


Option Explicit

Const MapRowOffset As Integer = 5
Const MapHexColOffset As Integer = 21
Const MapDecColOffset As Integer = 4

Public Sub GenerateAndSaveHexFile(HexSavePath As Variant)
'   We'll take the relevant data from the EEPROM map and output it appropriately in a new text file.  To generate a _
    hex file, the SaveAs filepath has been given the extension "*.hex"
    Dim HexLine(0 To 64) As String, NewFile As Integer, NumSum As Integer, CheckSumVal As Integer
    Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer
    
'   MAKE SURE that everything is set properly before writing the hex code
    Call ResetCycleRequirementValues
    Call TransposeCycleInfo
    
    Application.ScreenUpdating = False
    
    Worksheets("EEPROM Map").Activate
    For i = 0 To 63
        
        HexLine(i) = ":10"  'Start of a record
        NumSum = 16
        NumSum = NumSum + ((i * 16) \ 256)
        NumSum = NumSum + ((i * 16) Mod 256)
        
        j = i + MapRowOffset
        
        HexLine(i) = HexLine(i) & Cells(j, MapHexColOffset) 'This cell contains the Offset value
        HexLine(i) = HexLine(i) & "00"  'This indicates that we're talking about a data record
        
'       Scan through each column containing hex data and concatenate the columns in a row to generate a hex line, _
        also add the Decimal values of the columns to perform a checksum calculation
        For k = 0 To 15
            l = k + 2
            m = k + MapDecColOffset
(THE PROBLEM IS HERE BELOW)
            HexLine(i) = HexLine(i) & Cells(j, MapHexColOffset + l)
            NumSum = NumSum + Cells(j, m)
        
            
            
        Next k
'       Take care of the checksum value
        NumSum = NumSum And 255
        If NumSum <> 0 Then
            CheckSumVal = 256 - NumSum
        Else
            CheckSumVal = 0
        End If
        HexLine(i) = HexLine(i) & SetHexLength2(CheckSumVal)
    Next i
    
    HexLine(64) = ":00000001FF"
    
    NewFile = FreeFile
    Open HexSavePath For Output As #NewFile
    
    For i = 0 To 64
        Print #NewFile, HexLine(i)
    Next i
    
    Close NewFile
    Worksheets("Cycle").Activate
    Application.ScreenUpdating = True
    
End Sub  

[Edited by chcarlill on 07-04-2009 at 01:35 PM GMT]

07-04-2009 at 07:23 PM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 637
icon Re: excel vb project created in 2000 not working correctly in 2002

maybe in this line

NumSum = NumSum + Cells(j, m)

you are trying to add a non numeric cell to your sum
you should first check if the cell contains a valid numeric value and then add it to the sum

If IsNumeric(Cells(j, m)) Then
     NumSum = NumSum + Val(Cells(j, m))
End If

____________________________
AndreaVB

Ads by Lake Quincy Media
08-04-2009 at 08:41 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : excel vb project created in 2000 not working correctly in 2002
Previous Topic (daily function)Next Topic (Using vb to read data fomr afile an dinput data into excel to change cell value) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder