如何让我的程序根据用户输入的内容选择正确的交付? [英] How do i get my program to select the proper delivery based on what the user inputs?

查看:77
本文介绍了如何让我的程序根据用户输入的内容选择正确的交付?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Public class frmMain


Private Sub btnExit_Click(ByVal sender As Object,ByVal e As System.EventArgs)处理btnExit.Click

Me.Close( )

End Sub


Private Sub frmMain_Load(ByVal sender As Object,ByVal e As System.EventArgs)Handles Me.Load

''用值填充列表框

lstDelivery.Items.Add(" Mail - Standard")

lstDelivery.Items.Add("邮件 - 优先级")

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)处理txtPartNum.Enter

txtPartNum.SelectAll()

End Sub


Private Sub txtPartNum_Tex tChanged(ByVal sender As Object,ByVal e As System.EventArgs)处理txtPartNum.TextChanged

''清除列表框选择


End Sub


Private Sub btnDelivery_Click(ByVal sender As Object,ByVal e As System.EventArgs)处理btnDelivery.Click


Dim strtxtPartNum As String

Dim Index As Integer

Dim lstDelivery()As String = {" MP"," MS"," FS" ;,FO,U}


strtxtPartNum = txtPartNum.Text.ToUpper.ToString


如果strtxtPartNum赞" ## [AZ] [AZ]"那么

lstDelivery.SelectedIndex = 1


ElseIf strtxtPartNum赞&## [A-Z]然后


Else

MessageBox.Show(无效的部件号,_

"部件号",MessageBoxButtons。好的,_

MessageBoxIcon.Information)


结束如果


End Sub



结束类

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

推荐答案

请重新输入您的问题并更清楚一点。根据这段代码,我不明白你要做什么。


除非我遗漏了什么,

基于标题单独你的帖子我会假设你有三个子服务器做类似子联邦快递(),子UPS(),子USPS()等等,然后你会像这样调用这些潜艇:
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:
展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


这应该允许用户输入一个部件号,如(## [AZ] [AZ])或类似## [AZ] "意味着用户可以输入73mp或45U,它应该选择(突出显示)列表框中的相应代码,否则显示消息无效的部件号。必须在此代码中使用like运算符。
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.


如果您要让应用程序说他们的部件号无效,为什么要使用''like''运算符?

我认为做你想做的最好的方法是在数据库中创建一个表 - 将所有有效的部件号存储在一列中,并将交付方法列表框的相应索引号存储在另一列中,如下所示:

PartNum --------- IndexNum


73mp ----------------- 2

45U ------------------- 1

33X ----------- -------- 1

22Y ------------------- 3

然后只需打开与表的连接并根据用户输入的内容检索索引。

从PartsTable中选择IndexNum,其中PartNum =''" &安培; txtPartNum.Text& "''"
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 & "'' "


这篇关于如何让我的程序根据用户输入的内容选择正确的交付?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆