Error when making Windows EXE

mozaharul

Active Member
Licensed User
Hi,
In a Sub program of my application used for backup, I initialized a local variable as hh_new_rec=0, then used it (in same Sub) in a loop (For..next)to count the inserted records. Then in a listbox, message is added to show the number of records inserted in the database.
The application runs fine on the desktop (made for desktop), but when try to make Windows EXE it gives error message as attached. As I can understand, the message says variable of string type cannot be added using the operator +, but I did not declare the variable as string. Off course, there is a mistake on my part. Please correct me.

Sub x
--- ---
--- ---
hh_new_rec=0 ‘a local variables initialized
--- ---
--- ---
For a= 0 to some_value
cmd2.CommandText="select Backup_Date from "& k &" where Backup_Date='"&table2.Cell("Backup_Date",a)&"'" 'selecting form Device table of Master database
cmd2.ExecuteTable("table3",0)
If table3.RowCount=0 Then
cmd2.CommandText="insert into "& k &" values('"&table2.Cell("device_id",a)&"','"&table2.Cell("Backup_Date",a)&"')"
cmd2.ExecuteNonQuery
hh_new_rec=hh_new_rec+1 'counts the inserted row
Else
cmd2.CommandText="update device set device_ID='"&table2.Cell("device_id",a)&"'where backup_date='"&Date(Now)&"';"
cmd2.ExecuteNonQuery
End If
If hh_new_rec > 0 Then
listbox1.Insert (i,&" "&hh_new_rec & " record(s) inserted in the " &K & " Table " & "at " & Time(Now))
End If
Next
--- ---
--- ---
End sub


regards.
 

klaus

Expert
Licensed User
Longtime User
In this line
B4X:
listbox1.Insert (i,[COLOR=red]&[/COLOR]" "&hh_new_rec & " record(s) inserted in the " &K & " Table " & "at " & Time(Now))
the first & must be removed and the line looks like
B4X:
listbox1.Insert (i," "&hh_new_rec & " record(s) inserted in the " &K & " Table " & "at " & Time(Now))

Best regards.
 

Cableguy

Expert
Licensed User
Longtime User
This is puzzling me....:):sign0161:

Quote:
listbox1.Insert (i,&" "&hh_new_rec & " record(s) inserted in the " &K & " Table " & "at " & Time(Now))

Why use the ampersand in a known contiguous string?

Woulnd't this work as well?
Code:
listbox1.Insert (i," "&hh_new_rec & " record(s) inserted in the " &K & " Table at " & Time(Now))
 
Top