473,806 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I'm going nuts please help with homework

This is not working and for my life I can't figure out why:

Private Sub Button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim firstLetter As String
firstLetter = empIDtextBox.Te xt.Remove(1, 3)
firstLetter = firstLetter.ToU pper()
Label2.Text = firstLetter
If firstLetter <"F" Or firstLetter <"P" Then
Dim button As DialogResult
button = MessageBox.Show ("First letter must be F or P!", _
"Error Message", MessageBoxButto ns.OK,
MessageBoxIcon. Error, _
MessageBoxDefau ltButton.Button 1)
If button = Windows.Forms.D ialogResult.OK Then
empIDtextBox.Te xt = ""
empIDtextBox.Fo cus()
End If
End If

End Sub
End Class


The program is much more complex but I can't even get this part to
work. The input is a 4 character string such as "f123"

It should strip out the last 3 characters and change the first letter
to upper case.

If I take out the "Or firstLetter <"P" " then it's ok.

Label2 outputs the correct letter of "F" but still gives me an error
message.

"f123" should work and so should "p123"

My brain is thinking if firstLetter is not F or firstLetter is not P
then give error message, but that ain't workin' for me.

TIA,

Max
Oct 23 '06 #1
1 3016
This is not working and for my life I can't figure out why:
>
If firstLetter <"F" Or firstLetter <"P" Then
Think about what this If-Then statement does... yes, if firstLetter is any
letter other than "F" or "P", then firstLetter meets your test BUT because
you used OR... if firstLetter is an "F" then it is not a "P"; and if it is a
"P", then it is not an "F"... these will also meet your test.

For future reference...

Almost everybody in this newsgroup is using VB6 or lower. While you may get
a stray answer to VB.NET (including VB2003, VB2005 and VB Express which have
dropped .NET from their names) questions here, you should ask them in
newsgroups devoted exclusively to .NET programming (the languages are
different enough to warrant separate newsgroup support). Look for newsgroups
with either the word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups for Visual Basic .NET
related questions...

microsoft.publi c.dotnet.langua ges.vb
microsoft.publi c.dotnet.langua ges.vb.upgrade
microsoft.publi c.dotnet.langua ges.vb.controls
microsoft.publi c.dotnet.langua ges.vb.data

And these for more general .NET questions

microsoft.publi c.dotnet.genera l
microsoft.publi c.vsnet.general

Note: There are many other .NET newgroups (use the first three "fields" from
the last two as templates when searching for them), but the above ones
should get you started.

Rick
Oct 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1877
by: Jim Davidson | last post by:
Here's what I'm trying to do: I have a string with 30 numbers in it. I want to generate a random number between 0 an 30, go to that position in the string and get that number. Here is the code you can run it and see it doesn't work. I'm new at this (only about a week) but I thought this should work. Please help. It's probably something simple, but I don't see it.
14
1657
by: HP | last post by:
Hi All i have confussion regarding given problem please help me out 4. What happens with the following program: void main(){ myclass* pmc = new myclass; pmc = 0; delete pmc;}
4
1222
by: Johnny Emde | last post by:
Hello Newsgroup I'm about going nuts!!! Sometime when I coding a asp.net (using C#) I'll get this wierd error. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
1
1568
by: windandwaves | last post by:
Hi I have the following file: --myfile.php <?php if($s) { echo $s; session_id($s); session_start;
4
2090
by: Kausar.Nazir | last post by:
Pronlem# 1: How can I Create a notepad file named number.txt which consists of int type numbers separated with new lines on your hard disk, a program which read the numbers form this file and show them to screen, also display the total numbers in files and largest and smallest numbers to the screen. Please guide me I will be very thank full to you. problem # 2: Write a simple structure named Students. This structure consists of three...
62
2736
by: vubaboota | last post by:
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C Q1: Write a program using malloc function. In which you take input from user and allocate memory equal to square of this number. Which multiply numbers and draw a table in the following format? Hint: User enters 3 then program allocates equal to 9 integer memories. Output:1
19
1970
by: mohammaditraders | last post by:
a program which consists of a class named Student, the class should consists of three data members Name, Ob_marks, Total_marks and two member functions Cal_percentage() which calculate the percentage of the student by the formula (Ob_marks * 100 ) / Total_marks and Display() which show all information of the student. The class should also contain the default constructor which initializes all the data member of the class. In main program...
5
1422
by: Shelly | last post by:
This ASPX/SqlServer stuff is driving me nuts. 1 - In a previous post I said I had four tables and all were showing up in Object Explorer (MS SQL Server Management Studio Express), but when I went to do a query using the query text editor, only two of the tables showed up. Then, mysteriously, the problem went away. Now, it is back. 2 - My insert into a table failed from the debug version in Web Developer, so I copied that SQL call and...
16
342
by: jimmy.musselwhite | last post by:
Hello all It would be great if I could make a number that can go beyond current size limitations. Is there any sort of external library that can have infinitely huge numbers? Way way way way beyond say 5x10^350 or whatever it is? I'm hitting that "inf" boundary rather fast and I can't seem to work around it. Thanks!
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.