Home > Software engineering >  Vb connection TXT file, read TXT file how to format the name and code rate corresponding to
Vb connection TXT file, read TXT file how to format the name and code rate corresponding to

Time:09-16

Vb connection LST file, a text box 1 and 2 input data, click on add display list1 and combo1 below, click save to add data in files,

Next time you run the program, the program automatically read from the file content, the result is all of the data in the drop-down box
what I want is a drop-down box only show the front I input format of ABC, and how to make a drop-down box with the rate corresponding to the selected format name (ABC chose format, for example, how to make it corresponds to 123? Because below calculate)
O bosses

CodePudding user response:

Even if the "records" save in a text file, you somehow have to ensure that "standard format"!!!!!!!!!

Look at your "record", some "format name" and "rate" the two "key",
(also is bad, its name, called "keywords" for now ^_^)
Some have only a "format name" without any keywords, nor rate information (of course it's not a problem),

What do you think of that record information, when remembering file data, can facilitate processing!



Was a very simple thing, but because you remember the "mess" and become difficult to deal with,
Said a "specific" points, is:
Either you put all of the records (is the "text" in a row), unified respectively dubbed "format name" and "rate";
Don't the "key words", or to format the name and code rate information separated by a "special characters",
Such as use of es semicolon (assuming the format name will not appear in the "semicolon" character), comma (assuming... Like the previous),
Format name will appear in character, this kind of "no crown keyword" circumstances will not be able to as the "separator",
Es of space, for example, you are in the format of the name "Half" D1, it obviously can't use it to make separators,
After the "format specification", solve your "problem" is simple;
And "format name only, no rate", also is not a "problem",

CodePudding user response:

reference 1/f, a toast to invite the bright moon response:
even if the "record information in a text file saved, you somehow have to ensure that" standard format "!!!!!!!!!

Look at your "record", some "format name" and "rate" the two "key",
(also is bad, its name, called "keywords" for now ^_^)
Some have only a "format name" without any keywords, nor rate information (of course it's not a problem),

What do you think of that record information, when remembering file data, can facilitate processing!



Was a very simple thing, but because you remember the "mess" and become difficult to deal with,
Said a "specific" points, is:
Either you put all of the records (is the "text" in a row), unified respectively dubbed "format name" and "rate";
Don't the "key words", or to format the name and code rate information separated by a "special characters",
Such as use of es semicolon (assuming the format name will not appear in the "semicolon" character), comma (assuming... Like the previous),
Format name will appear in character, this kind of "no crown keyword" circumstances will not be able to as the "separator",
Es of space, for example, you are in the format of the name "Half" D1, it obviously can't use it to make separators,
After the "format specification", solve your "problem" is simple;
And "format name only, no rate", also is not a "problem",

This is my negligence... Can remove the keyword format name and code rate, then the standard format, specific symbols are separated by Spaces, input can be specified when there can be no Spaces, this format specification, also please advise the

CodePudding user response:

If you have a List. The LST is "separated by a space", consult the code,
If there is a problem to say again...

 Option Explicit 

Private arrData () As String
Private mlMaxSN As Long

Private Sub LoadList ()
Dim strTemp As String
Dim i& As Long, k

StrTemp=App. Path & amp; "\ List LST
"The Open strTemp For Input As # 1
K=LOF (1)
StrTemp=StrConv (InputB $(k, # 1), vbUnicode)
The Close
ArrData=https://bbs.csdn.net/topics/Split (strTemp, vbCrLf)
For I=0 & amp; The To UBound (arrData ())
StrTemp=arrData (I)
K=InStr (strTemp, "")
If (0=k) Then the Exit For
Me.Com bo1. AddItem Left $(strTemp, k - 1)
ArrData (I)=Mid $(strTemp, k + 1)
Next
MlMaxSN=I - 1
End Sub

Private Sub Combo1_Click ()
Dim As Long I

I=Combo1. ListIndex - 5 'Combo1 "standard format" there are five of the
If (0 & gt; I) Then
Text2. Text=""
The Else
If (I & gt; Then mlMaxSN)
Text2. Text=""
The Else
Text2. Text=arrData (I)
End the If
End the If
End Sub

Private Sub Form_Load ()
'do you other processing...

Call LoadList
End Sub
  • Related