Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / September 2005

Tip: Looking for answers? Try searching our database.

Cint(null)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wael - 29 Sep 2005 13:39 GMT
Hi

I have code that stores integer data from the control to the database.
(I am using Option Strict). The problem is when I try to do the code
below, I get that the string is not properly formatted because there is
no value. Each page has a lot of variables. Is there a way to solve
that problem without having to have an IF block for each variable?

myNewRow("score1") = CInt(SCORE1.Text)

Thanks
W
Peter van der Goes - 29 Sep 2005 15:39 GMT
> Hi
>
[quoted text clipped - 8 lines]
> Thanks
> W

Yes, you do need to evaluate the input in interface objects before
attempting conversions.
What you describe is an input failure where the user failed to enter
anything into the textbox, correct?
You need to add code to trap missing/inappropriate input and force the user
to enter the correct stuff *before* you attempt any conversions or storage
in your database.

Signature

Peter [MVP Visual Developer]
Jack of all trades, master of none.

Wael - 29 Sep 2005 17:26 GMT
cecil - 29 Sep 2005 21:05 GMT
Wael,
    Do your db fields allow nulls?  Or do you want to default to zero
( or int.Max or whatever) if the Score1.Text is null.  If you want null
to become a default value then create a global function in a module or
a shared method of a utility class:

public function FixNull(str as string,int nullVal) as integer
    If str is null then
        FixNull = nullVal
    Else
         FixNull = Cint(str)
    End if
End Function

Now your code can use FixNull in place of CInt.
You may also deal with if str is not numeric but chances are you want
the exception to escape.

Cecil Howell
MCT, MCSD, MCAD.NET, MCDFSWQZ
Wael - 30 Sep 2005 02:33 GMT
I did something similar to that. I have a global function that takes
the datarow and the value and sets it accordingly

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.