Answered by:
how to gnore Negative signal in excel
Question

hi
I want to find the difference between the two columns of the excel when exporting data from the Datagrid View with the negative signal ignored
The following code works but does not delete the negative signFor I = 2 To excelWorksheet.UsedRange.Rows.Count If String.IsNullOrEmpty(excelWorksheet.Range("f" & I).Value) = False AndAlso String.IsNullOrEmpty(excelWorksheet.Range("g" & I).Value) = False Then excelWorksheet.Range("h" & I).Value = "=f" & I & "g" & I
' End If Next
try code not work
For I = 2 To excelWorksheet.UsedRange.Rows.Count If String.IsNullOrEmpty(excelWorksheet.Range("f" & I).Value) = False AndAlso String.IsNullOrEmpty(excelWorksheet.Range("g" & I).Value) = False Then excelWorksheet.Range("h" & Math.Abs(I)).Value = "=f" & I & "g" & I ' End If Next
Answers

What you are attempting to do should fail as you have option strict off and the compiler is deciding things for you.
Your logic would work in JavaScript as JavaScript understand what you are doing.
For it to work in .NET with zero methods, only math
Dim i As Integer = 3 Dim result = "f" & (i * 1).ToString()
Result is f3
Dim i As Integer = 3 Dim result = "f" & (i * 1).ToString()
Result f3
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums  moderator
 Marked as answer by ahmeddc Sunday, December 23, 2018 11:26 PM
All replies

Hi
I do not understand your question fully. There is something about 'ignoring a minus sign' which I read as finding the Absolute value of a subtraction. If so, then here is an example:
Dim a, b As Double a = 1.2345 : b = 4.5678 Dim res1 As Double = Math.Abs(a  b) ' res1 = 3.333300000000 Dim res2 As Double = Math.Abs(b  a) ' res2 = 3.333300000000
Regards Les, Livingston, Scotland

What you are attempting to do should fail as you have option strict off and the compiler is deciding things for you.
Your logic would work in JavaScript as JavaScript understand what you are doing.
For it to work in .NET with zero methods, only math
Dim i As Integer = 3 Dim result = "f" & (i * 1).ToString()
Result is f3
Dim i As Integer = 3 Dim result = "f" & (i * 1).ToString()
Result f3
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums  moderator
 Marked as answer by ahmeddc Sunday, December 23, 2018 11:26 PM