stu14t Active Member Licensed User Longtime User Nov 10, 2012 #1 I'm having a problem with this code : Code: Copy Public Sub Display_upDate() Dim NOB As String Dim TBTP As String Dim PNTP As String NOB = CStr(NumOfBlows) TBTP = CStr(TotBlows(TestPoint)) PNTP = CStr(Pen(TestPoint)) Table1.AddRow(NOB,TBTP,PNTP) End Sub And it's throwing an error at compilation: Compiling code. Error Error compiling program. Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1} Occurred on line: 649 Table1.AddRow(NOB,TBTP,PNTP) Word: nob I'm using the following code, kindly supplied by Jost aus Soest, to force the integer and the two 1 dimensional arrays to strings, so the table can take them: Code: Copy Sub CStr(i As Int) As String Return "" & i End Sub What am I missing? Many thanks
I'm having a problem with this code : Code: Copy Public Sub Display_upDate() Dim NOB As String Dim TBTP As String Dim PNTP As String NOB = CStr(NumOfBlows) TBTP = CStr(TotBlows(TestPoint)) PNTP = CStr(Pen(TestPoint)) Table1.AddRow(NOB,TBTP,PNTP) End Sub And it's throwing an error at compilation: Compiling code. Error Error compiling program. Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1} Occurred on line: 649 Table1.AddRow(NOB,TBTP,PNTP) Word: nob I'm using the following code, kindly supplied by Jost aus Soest, to force the integer and the two 1 dimensional arrays to strings, so the table can take them: Code: Copy Sub CStr(i As Int) As String Return "" & i End Sub What am I missing? Many thanks
margret Well-Known Member Licensed User Longtime User Nov 10, 2012 #2 You are trying to cast an array to a string? you may need to post more code. The error states a string to an array. If you log(NOB) just before the .AddRow, what does the log show? Last edited: Nov 10, 2012 Upvote 0
You are trying to cast an array to a string? you may need to post more code. The error states a string to an array. If you log(NOB) just before the .AddRow, what does the log show?
stu14t Active Member Licensed User Longtime User Nov 10, 2012 #3 Thanks for the reply Margret The variable NumOfBlows is not an array it's an integer, and that's the one throwing the compilation error. The line throwing the problem is line 649: Code: Copy Table1.AddRow(NOB,TBTP,PNTP) The conversion to string has worked but I don't understand the String.Rank=0 and String.Rank =1. The compiler seems to dislike the way I've forced it to a string. Compiling code. Error Error compiling program. Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1} Occurred on line: 649 Table1.AddRow(NOB,TBTP,PNTP) Word:nob Can I Log it if it's a compilation error and not runtime exception? Last edited: Nov 10, 2012 Upvote 0
Thanks for the reply Margret The variable NumOfBlows is not an array it's an integer, and that's the one throwing the compilation error. The line throwing the problem is line 649: Code: Copy Table1.AddRow(NOB,TBTP,PNTP) The conversion to string has worked but I don't understand the String.Rank=0 and String.Rank =1. The compiler seems to dislike the way I've forced it to a string. Compiling code. Error Error compiling program. Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1} Occurred on line: 649 Table1.AddRow(NOB,TBTP,PNTP) Word:nob Can I Log it if it's a compilation error and not runtime exception?
J Jost aus Soest Active Member Licensed User Longtime User Nov 10, 2012 #4 Where and how is Table1 declared? Upvote 0
stu14t Active Member Licensed User Longtime User Nov 10, 2012 #5 Jost aus Soest Thanks for the reply and the code too I've found the error and it was my fault. I missed some code out the line should read: Code: Copy Table1.AddRow(Array As String(NOB,TBTP,PNTP)) And not Code: Copy Table1.AddRow(NOB,TBTP,PNTP) Upvote 0
Jost aus Soest Thanks for the reply and the code too I've found the error and it was my fault. I missed some code out the line should read: Code: Copy Table1.AddRow(Array As String(NOB,TBTP,PNTP)) And not Code: Copy Table1.AddRow(NOB,TBTP,PNTP)
J Jost aus Soest Active Member Licensed User Longtime User Nov 11, 2012 #6 Great, that it works now! You're welcome! Upvote 0