Private Sub CommandButton7_Click()

'UAD_FLG

    Dim sValue1 As String
    Dim sValue2 As String
    Dim sValue3 As String
    Dim sValue4 As String
    Dim sValuex As String
    Dim sscript As String
    Dim sscript2 As String
    Dim sscript3 As String
    Dim x As String
    Dim finalstring As String
    
    Dim temp1 As Integer
    
    
    
   
    Dim lRow As Long
    Dim lRowx As Long
    Dim lColValue1 As Long
    Dim lColValue2 As Long
    Dim lColValue3 As Long
    Dim lColValue4 As Long
    Dim lColValue5 As Long
    Dim stemp1 As String
    Dim sum As Integer
    
    Dim a As String
    
  
    
    
    '====================================
    'FLAG 1 CALL
    '====================================
    lRow = 3
    lColValue1 = 5
    lColValue2 = 11
    lColValue3 = 12
    lColValue4 = 13
    
     Call WriteToTextFile10("")
    Call WriteToTextFile10("---------UDA_FLG started")

       
    While Not Cells(lRow, lColValue1) = ""
        sValue1 = Cells(lRow, lColValue1)
        sValue2 = Cells(lRow, lColValue2)
        sValue3 = Cells(lRow, lColValue3)
        sValue4 = Cells(lRow, lColValue4)
        
        sscript = "INSERT INTO SYS_PARAMS(SECTION_NM,VARIABLE_NM, VARIABLE_VALUE, CREATE_ID, CREATE_DT, UPDATE_ID, UPDATE_DT) Values('UAD_FLG','"
         
        sscript2 = ",'P22919',SYSDATE,'', NULL);"
       temp1 = 0
      sum = 0
       
       For lRowx = 3 To 78
            For lColValue5 = 11 To 13
            sValuex = Cells(lRowx, lColValue5)
            If lColValue5 <> 13 Then
                If sValuex <> "" Then
                sscript3 = sscript3 & sValuex & ","
                 sValuex = Cells(lRowx, lColValue5)
                 Else
                 val = CInt(sValuex)
                 sum = sum + val
                 If sum == 100 Then
                sscript3 = sscript3 & "'"
                Else
                 sscript3 = sscript3 & temp1 & ","
                 End If
                 End If

I am getting typemismatch when i am trying to use CInt function here.Can you give me some idea to help me out.

Thanks
Namish

Private Sub CommandButton7_Click()

'UAD_FLG

    Dim sValue1 As String
    Dim sValue2 As String
    Dim sValue3 As String
    Dim sValue4 As String
    Dim sValuex As String
    Dim sscript As String
    Dim sscript2 As String
    Dim sscript3 As String
    Dim x As String
    Dim finalstring As String
    
    Dim temp1 As Integer
    
    
    
   
    Dim lRow As Long
    Dim lRowx As Long
    Dim lColValue1 As Long
    Dim lColValue2 As Long
    Dim lColValue3 As Long
    Dim lColValue4 As Long
    Dim lColValue5 As Long
    Dim stemp1 As String
    Dim sum As Integer
    
    Dim a As String
    
  
    
    
    '====================================
    'FLAG 1 CALL
    '====================================
    lRow = 3
    lColValue1 = 5
    lColValue2 = 11
    lColValue3 = 12
    lColValue4 = 13
    
     Call WriteToTextFile10("")
    Call WriteToTextFile10("---------UDA_FLG started")

       
    While Not Cells(lRow, lColValue1) = ""
        sValue1 = Cells(lRow, lColValue1)
        sValue2 = Cells(lRow, lColValue2)
        sValue3 = Cells(lRow, lColValue3)
        sValue4 = Cells(lRow, lColValue4)
        
        sscript = "INSERT INTO SYS_PARAMS(SECTION_NM,VARIABLE_NM, VARIABLE_VALUE, CREATE_ID, CREATE_DT, UPDATE_ID, UPDATE_DT) Values('UAD_FLG','"
         
        sscript2 = ",'P22919',SYSDATE,'', NULL);"
       temp1 = 0
      sum = 0
       
       For lRowx = 3 To 78
            For lColValue5 = 11 To 13
            sValuex = Cells(lRowx, lColValue5)
            If lColValue5 <> 13 Then
                If sValuex <> "" Then
                sscript3 = sscript3 & sValuex & ","
                 sValuex = Cells(lRowx, lColValue5)
                 Else
                 value = CInt(sValuex)   
                  
                 sum = sum + value
                 If sum = 100 Then
                sscript3 = sscript3 & "'"
                Else
                 sscript3 = sscript3 & temp1 & ","
                 End If
                 End If

I am getting typemismatch when i am trying to use CInt function here.Can you give me some idea to help me out.
Thanks
Namish

I have modified the test a bit before i put val even val is a reserved keyword.

Hi,

Yes VAL is a Reserved Word. Instead of CInt use Val()

value = Val(sValuex)

U may Get Error if Integer declared variables cross 32k


REgards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.