Click here to Skip to main content
15,920,005 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Using vb.net timer contol in vb6 Pin
Paul Conrad8-Oct-09 16:50
professionalPaul Conrad8-Oct-09 16:50 
Question3D illumination Pin
bytelogik7-Oct-09 22:37
bytelogik7-Oct-09 22:37 
AnswerRe: 3D illumination Pin
Richard MacCutchan7-Oct-09 22:49
mveRichard MacCutchan7-Oct-09 22:49 
AnswerRe: 3D illumination Pin
Mycroft Holmes8-Oct-09 18:01
professionalMycroft Holmes8-Oct-09 18:01 
QuestionDetecting Computer restart Pin
RyJaBy7-Oct-09 7:06
RyJaBy7-Oct-09 7:06 
AnswerRe: Detecting Computer restart Pin
nlarson117-Oct-09 8:25
nlarson117-Oct-09 8:25 
GeneralRe: Detecting Computer restart Pin
RyJaBy7-Oct-09 8:50
RyJaBy7-Oct-09 8:50 
QuestionValidation of the date and number [SOLVED] Pin
Frauenarzt7-Oct-09 5:58
Frauenarzt7-Oct-09 5:58 
Hey, I'm a very beginner so please don't laugh Wink | ;-)


I want to validate a date user inputs:
Dim scr_time As Date
dim ok as boolean


System.Console.WriteLine("Enter screening date & time [DD/MM/YYYY HH/MM]")
        scr_time = System.Console.ReadLine()

        ValidateDate(scr_time, ok)



Sub ValidateDate(ByVal scr_time As String, ByRef bol_isvalid As Boolean)
        If IsDate(scr_time) Then
            bol_isvalid = True
        Else
            bol_isvalid = False
        End If
    End Sub


When entered 'notdate' the error says "Conversion from string "notdate" to type 'Date' is not valid."

Is that because I declared scr_time as date, instead of string? If I declare the date as string is
now >= scr_date
going to work fine?



Second question regarding validation of number:
Dim cnt_adult As Integer

System.Console.WriteLine("How many adult tickets required?")
        cnt_adult = System.Console.ReadLine()

        ValidateNumber(cnt_adult, ok)

        If ok Then
            System.Console.WriteLine()
        Else
            System.Console.WriteLine("Incorrect value. Press any key to try again.")
            System.Console.ReadKey()
            GoTo sale
        End If


Sub ValidateNumber(ByVal text As String, ByRef bol_isvalid As Boolean)
        If IsNumeric(text) Then
            bol_isvalid = True
        Else
            bol_isvalid = False
        End If
    End Sub


"Conversion from string "t" to type 'Integer' is not valid."

I know the solution would be to declare the variable cnt_adult as string, by I need it as integer so I can multiply it with another integer later.

modified on Wednesday, October 7, 2009 3:41 PM

AnswerRe: Validation of the date and number Pin
EliottA7-Oct-09 6:08
EliottA7-Oct-09 6:08 
GeneralRe: Validation of the date and number Pin
Frauenarzt7-Oct-09 6:27
Frauenarzt7-Oct-09 6:27 
GeneralRe: Validation of the date and number Pin
Henry Minute7-Oct-09 7:18
Henry Minute7-Oct-09 7:18 
GeneralRe: Validation of the date and number Pin
Frauenarzt7-Oct-09 7:32
Frauenarzt7-Oct-09 7:32 
GeneralRe: Validation of the date and number Pin
Henry Minute7-Oct-09 7:38
Henry Minute7-Oct-09 7:38 
GeneralRe: Validation of the date and number [modified] Pin
Frauenarzt7-Oct-09 7:47
Frauenarzt7-Oct-09 7:47 
GeneralRe: Validation of the date and number Pin
Henry Minute7-Oct-09 8:33
Henry Minute7-Oct-09 8:33 
GeneralRe: Validation of the date and number [modified] Pin
Frauenarzt7-Oct-09 9:18
Frauenarzt7-Oct-09 9:18 
GeneralRe: Validation of the date and number Pin
EliottA7-Oct-09 9:22
EliottA7-Oct-09 9:22 
GeneralRe: Validation of the date and number Pin
Ian Shlasko7-Oct-09 9:38
Ian Shlasko7-Oct-09 9:38 
GeneralRe: Validation of the date and number Pin
Henry Minute7-Oct-09 10:21
Henry Minute7-Oct-09 10:21 
QuestionConnecting VB2008 Express to SQL Server 2008 Developer Pin
Garth Geoghan7-Oct-09 5:08
Garth Geoghan7-Oct-09 5:08 
AnswerRe: Connecting VB2008 Express to SQL Server 2008 Developer Pin
EliottA7-Oct-09 5:11
EliottA7-Oct-09 5:11 
GeneralRe: Connecting VB2008 Express to SQL Server 2008 Developer Pin
Garth Geoghan7-Oct-09 5:33
Garth Geoghan7-Oct-09 5:33 
GeneralRe: Connecting VB2008 Express to SQL Server 2008 Developer Pin
Garth Geoghan7-Oct-09 7:12
Garth Geoghan7-Oct-09 7:12 
GeneralRe: Connecting VB2008 Express to SQL Server 2008 Developer Pin
EliottA7-Oct-09 7:19
EliottA7-Oct-09 7:19 
GeneralRe: Connecting VB2008 Express to SQL Server 2008 Developer Pin
Garth Geoghan7-Oct-09 7:23
Garth Geoghan7-Oct-09 7:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.