•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 455,964 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,630 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 4059 | Replies: 2
![]() |
•
•
Join Date: Nov 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Below is my code and I get the above mentioned error in vb.net. I am trying to pass blank in integer .
Private ReadOnly Property GPLegalEntityId() As Integer
Get
If Request.QueryString("GPLegalEntityId") = "" Then
Return ""
Else
Return Convert.ToInt32(Request.QueryString("GPLegalEntityId"))
End If
End Get
End Property
Private ReadOnly Property GPLegalEntityId() As Integer
Get
If Request.QueryString("GPLegalEntityId") = "" Then
Return ""
Else
Return Convert.ToInt32(Request.QueryString("GPLegalEntityId"))
End If
End Get
End Property
•
•
Join Date: Sep 2007
Posts: 1,058
Reputation:
Rep Power: 4
Solved Threads: 61
You cannot convert an empty string to an integer, that's why you are receiving the error. A querystring is treated as a string. If the length of the querystring is above 0 numbers, and contains no letters, this code will work. You will receive the same error, however, if your querystring is 1231k213, all due to the K. You have to remove the letters and characters from your string, and then convert it. To do this, use something like the function below to make it an integer. Also, make sure that the numbers do not exceed the integer length, otherwise you will need to convert it into a LONG instead of INTEGER.
You may also use string instead of integer to quickily put a fix to your problem, but you will have this problem again if there are more than integers in your querystring.
You may also use string instead of integer to quickily put a fix to your problem, but you will have this problem again if there are more than integers in your querystring.
'Make Querystrings Ints
Public Function MakeInt(ByVal stringint As String) As String
Dim lngCount As Long
Dim strOut As String
if Len(stringint) > 0 then
for lngCount = 1 to len(stringint)
if isnumeric(mid$(stringint, lngCount, 1)) then
strOut = strOut & mid$(stringint, lngCount, 1)
end if
next lngCount
end if
MakeInt = strOut
end function![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- vb.net Fill function (VB.NET)
- Unzip Function (VB.NET)
- how to cast a string type variable to LPCTSTR type (C++)
- Something about String.split("-"); problem (Java)
- help understanding "char" data type (C++)
- Cast from string "Display" to type "Interger" is not valid (VB.NET)
- This ought to be simple - extra spaces (PHP)
Other Threads in the ASP.NET Forum
- Previous Thread: crystal reports runtime design issue
- Next Thread: how can i createa slide show in aspx page



Linear Mode