Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET General (http://www.xtremevbtalk.com/-net-general/)
-   -   Vb.net assignment (http://www.xtremevbtalk.com/-net-general/328506-vb-net-assignment.html)

Jamarccus 12-03-2016 02:01 PM

Vb.net assignment
 
So I'm amidst taking my first programming class and now making a phone number validation function in a module that will decide whether or not a phone number is legit according to NANP guidelines.

What I'm feeling really stuck on is that when a number doesn't follow the guidelines I can't get the function to return a message or messagebox describing why the number isn't valid.

Here's a snippet of code showing what I can't figure out.

Option Strict On
Module PhoneNumberValidation

Public Function IsNumberValid(ByVal NumberInput As String) As Boolean

If NumberInput.Substring(1, 1).Equals("0") Or NumberInput.Substring(1, 1).Equals("1") Then

Return ("This number is invalid because Area Codes cannot begin with a 1 or 0.") ' <-- here's the message I want to return but it won't because it's a boolean value, if theres a way to change that, how so?


ElseIf NumberInput.Substring(1, 1).Equals("2") Then

End If

Return True

End Function

End Module



If anyone can help me out here I would appreciate it a ton!

Cerian Knight 12-03-2016 10:24 PM

Just an opinion, but your function definition seems too narrow. Yes, you might be able to solve this with overrides (though I'm not sure if return overrides exist) or something else. Why not just change this function definition or write another function called 'WhyIsNumberNotValid' (or, better yet, 'GetLastInvalidNumberErrorMessage') that returns a string?


All times are GMT -6. The time now is 09:19 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.