Reputation: 105
I have the following block of code:
Public Function GetDate(ByVal adate AS String) AS String
Dim len AS Integer = Len(adate) /*problem line*/
Dim strSubstr AS String = Mid(adate, 0, len-2)
Dim compStr AS String = strSubstr + "00"
return compStr
End Function
I'm getting an error:
Expression is not an array or method, and cannot have an argument list
I'm new to VB but I feel like I'm doing this correctly, what am I missing here?
EDIT:
This is what finally worked for me:
Public Function GetDate(ByVal adate AS String) AS String
Dim mylen AS Integer = adate.Length
Dim strSubstr AS String = adate.Substring(0, mylen-2)
Dim compStr AS String = strSubstr & "00"
return compStr
End Function
Upvotes: 0
Views: 466
Reputation: 105
This is what finally worked for me:
Public Function GetDate(ByVal adate AS String) AS String
Dim mylen AS Integer = adate.Length
Dim strSubstr AS String = adate.Substring(0, mylen-2)
Dim compStr AS String = strSubstr & "00"
return compStr
End Function
Upvotes: 0
Reputation: 1111
It looks like it was giving you an error because you were using a vb keyword (len) as a variable.
Try this:
Public Function GetDate(ByVal adate As String) As String
Dim myLen As Integer = Len(adate)
Dim strSubstr As String = Mid(adate, 0, myLen - 2)
Dim compStr As String = strSubstr + "00"
Return compStr
End Function
Upvotes: 1