Public Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' fills the list box with values
lstDelivery.Items.Add("Mail - Standard")
lstDelivery.Items.Add("Mail - Priority")
lstDelivery.Items.Add("FedEx - Standard")
lstDelivery.Items.Add("FedEx - Overnight")
lstDelivery.Items.Add("UPS")
End Sub
Private Sub txtPartNum_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPartNum.Enter
txtPartNum.SelectAll()
End Sub
Private Sub txtPartNum_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPartNum.TextChanged
' clears the list box selection
lstDelivery.SelectedIndex = -1
End Sub
Private Sub btnDelivery_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelivery.Click
Dim strtxtPartNum As String
Dim Index As Integer
Dim lstDelivery() As String = {"MP", "MS", "FS", "FO", "U"}
strtxtPartNum = txtPartNum.Text.ToUpper.ToString
If strtxtPartNum Like "##[A-Z][A-Z]" Then
lstDelivery.SelectedIndex = 1
ElseIf strtxtPartNum Like "##[A-Z]" Then
Else
MessageBox.Show("Invalid part number", _
"Part number", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End If
End Sub
End Class
which object type do you have for the user to type? if it is a text box then use this method - I'm assuming your textbox is called "txtPartNum"...... don't use the item list you are using ( {"MP", "MS", "FS", "FO", "U"}) <-- ignore this - instead call the value of the textbox directly and evaluate based on that value -
If txtPartNum.SelectedItem.Text Like "##MP" Then
-
lstDelivery.SelectedIndex = 0
-
ElseIf txtPartNum.SelectedItem.Text Like "##MS" Then
-
lstDelivery.SelectedIndex = 1
-
ElseIf txtPartNum.SelectedItem.Text Like "##FS" Then
-
lstDelivery.SelectedIndex = 2
-
ElseIf txtPartNum.SelectedItem.Text Like "##FO" Then
-
lstDelivery.SelectedIndex = 3
-
ElseIf txtPartNum.SelectedItem.Text Like "##U" Then
-
lstDelivery.SelectedIndex = 4
-
Else
-
MessageBox.Show("Invalid part number", _
-
"Part number", MessageBoxButtons.OK, _
-
MessageBoxIcon.Information)
-
-
End If
-
21 1573
please retype your question and be a bit clearer. I'm not understanding what you are trying to do based on this code.
unless I'm missing something,
based on the title of your post alone I would assume that you would have three subs that do something like sub Fedex(), sub UPS(), sub USPS() etc. then you would call those subs like so: -
if DropDownList1.selecteditem.Text = "FedEx" then
-
FedEx()
-
ElseIf DropDownList1.selecteditem.Text = "UPS" then
-
UPS()
-
ElseIf DropDownList1.selecteditem.Text = "USPS" then
-
USPS()
-
End If
-
-
this should allow the user to enter a part number like ("##[A-Z][A-Z]) or like "##[A-Z]" meaning the user can input 73mp or 45U and it should select(highlight) the appropriate code in the list box, else desplay the message Invalid part number. The like operator has to be used in this code.
why are you using a 'like' operator if you are enabling the application to say they have an invalid part number?
I think the best way to do what you want is to create a table in a database - store all of your valid part numbers in one column and the corresponding index number for the delivery method listbox in another column like so:
PartNum---------IndexNum
73mp-----------------2
45U-------------------1
33X-------------------1
22Y-------------------3
then just open a connection to your table and retrieve the index based upon what the user inputs.
Select IndexNum from PartsTable where PartNum = '" & txtPartNum.Text & "' "
My question should have been:
How do i get my program to select the proper delivery CODE based on a code that the user inputs.
Thats to deep yarbrough, i just need to use the like operator to compare the user code input (ie 33mp or 65FO) to string with the list box which has:
lstDelivery.Items.Add("Mail - Standard")
lstDelivery.Items.Add("Mail - Priority")
lstDelivery.Items.Add("FedEx - Standard")
lstDelivery.Items.Add("FedEx - Overnight")
lstDelivery.Items.Add("UPS")
Example if the user inouts any two number followed by MS it should select /highlight the ("Mail - Standard").. If the user inputs any two numbers followed by a U it should select/highlight)("UPS")
The string code is {"MP", "MS", "FS", "FO", "U"}
MP= lstDelivery.Items.Add("Mail - Standard")
MS=lstDelivery.Items.Add("Mail - Priority")
FS=lstDelivery.Items.Add("FedEx - Standard")
FO=lstDelivery.Items.Add("FedEx - Overnight")
U=lstDelivery.Items.Add("UPS")
Thats the way the teacher wants it...it has to be used in conjunction with the string i guess!
If you have VB on your pc I can send you the file so that you can run it and see what I need to do......
ok then how about this -
-
Dim DeliveryMeth as String = Substring(txtPartNum.Text(2,2))
-
-
if DeliveryMeth = "MP" then
-
lstDelivery.SelectedIndex = 1
-
ElseIf DeliveryMeth = "MS" then
-
lstDelivery.SelectedIndex = 2
-
ElseIf DeliveryMeth = "FS" then
-
lstDelivery.SelectedIndex = 3
-
ElseIf DeliveryMeth = "FO" then
-
lstDelivery.SelectedIndex = 4
-
ElseIf DeliveryMeth = "U" then
-
lstDelivery.SelectedIndex = 5
-
Else
-
MessageBox.Show("Invalid part number", _
-
"Part number", MessageBoxButtons.OK, _
-
MessageBoxIcon.Information)
-
-
End If
-
that might work, can i replace the = with LIKE
do you HAVE to use the like operator? is that part of an assignment or something?
yes it is part of my assignment......I have been working on it for over 3days!
ok well with my example, there is no need to use 'like' but I suppose it would work
now it just shows the message box when i use this code:
Dim strtxtPartNum As String
Dim txtPartNum() As String = {"MP", "MS", "FS", "FO", "U"}
strtxtPartNum = txtPartNum.ToString()
If strtxtPartNum Like "##MP" Then
lstDelivery.SelectedIndex = 0
ElseIf strtxtPartNum Like "##MS" Then
lstDelivery.SelectedIndex = 1
ElseIf strtxtPartNum Like "##FS" Then
lstDelivery.SelectedIndex = 2
ElseIf strtxtPartNum Like "##FO" Then
lstDelivery.SelectedIndex = 3
ElseIf strtxtPartNum Like "##U" Then
lstDelivery.SelectedIndex = 4
Else
MessageBox.Show("Invalid part number", _
"Part number", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
I know im a newbie but what am I doing wrong???????????????
which object type do you have for the user to type? if it is a text box then use this method - I'm assuming your textbox is called "txtPartNum"...... don't use the item list you are using ( {"MP", "MS", "FS", "FO", "U"}) <-- ignore this - instead call the value of the textbox directly and evaluate based on that value -
If txtPartNum.SelectedItem.Text Like "##MP" Then
-
lstDelivery.SelectedIndex = 0
-
ElseIf txtPartNum.SelectedItem.Text Like "##MS" Then
-
lstDelivery.SelectedIndex = 1
-
ElseIf txtPartNum.SelectedItem.Text Like "##FS" Then
-
lstDelivery.SelectedIndex = 2
-
ElseIf txtPartNum.SelectedItem.Text Like "##FO" Then
-
lstDelivery.SelectedIndex = 3
-
ElseIf txtPartNum.SelectedItem.Text Like "##U" Then
-
lstDelivery.SelectedIndex = 4
-
Else
-
MessageBox.Show("Invalid part number", _
-
"Part number", MessageBoxButtons.OK, _
-
MessageBoxIcon.Information)
-
-
End If
-
You assumed right! Im about to try ur solution right now!!!!!!!!!!!!!!
It underlines the txtPartNum.SelectedItem and show that SelectedItem is not a member of 'System.Windows.Forms.Textbox...After I Dim txtPartNum AS String it show that SelectedItem is not a member of String!
Wow, I am deeply indebted to you........It Works Yahoooooooooo. So now do I just click on choose the best answer?
thanks a Million$$$$$$$$$$$$$$$$$$$
your welcome.... as far as selecting best answer goes I'm not sure how that works - you're on your own there : )
Ok once again Thx, I will be looking for your ID if I have any more problems!!!!!!!!!!!!!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steve Lefevre |
last post by:
Hey folks --
I have a series of selectboxes on a web form. I would like to have a
javascript jump the focus to the next selectbox when the user presses a key.
Each box has the values 1 through...
|
by: Ben Hallert |
last post by:
Hi guys,
I'm trying to figure out what bone headed mistake I made on something I
put together. I've got a form (named 'context') that has a variable
number of select-multiple inputs on it. ...
|
by: tigrfire |
last post by:
I've been working on a program to try and play a game of Craps, based
on a version I found elsewhere - I didn't code the original, but I
added a few things such as a balance and wager system. I'm...
|
by: evilasukakitty |
last post by:
I too am new to the whole C++ language, and I am an eager beaver and wish I could absorb it all instantly, but I can't. The first program I wrote (very simple) was easy enough, using your basic cin...
|
by: Vortexmind |
last post by:
Hi all
I was wondering if this is possible in Javascript.
I want to make a bookmarklet. When a user launches it, it tells the
user to select an element in the page (for example a textarea) with...
|
by: Danielle |
last post by:
All -
I was asked to work on a project converting some weather data. The
program used to convert the data is written in Quick Basic. I am only a
novice programmer and while I can see from the...
|
by: vadrama |
last post by:
takes a list of grades and counts the amount A's, B's, C's etc...
I am using a while statement to count the total number of grades which works great, but my if and else statements to count how...
|
by: namcintosh |
last post by:
Hello, everyone.
Well, let me cut to the chase and explain my problem.
I am trying to devise a menu plan that uses the if/else if and the while loop. The program calculates the user's weight...
|
by: davidkoree |
last post by:
I mean not about cookie.
Does it have something to do with operating system or browser plugin?
I appreciate any help.
|
by: The.Daryl.Lu |
last post by:
Hi, two parts to my problem if someone can help address either one or
both:
1. I want to SELECT everything in the table if it matches the
criteria when the query button is pressed (this is just...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
|
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...
| |