Mr.M 62

Please post that code as of the start of the Sub to the end of that sub End Sub so that we can see what's wrong, but I think your code is outside the Sub that why you are getting those errors but that can be confirmed after you have posted the code as I stated above so that we can see what went wrong or what is wrong with your code.

Mr.M 62

I think what you are trying to say is that you want to Auto Complete when you are typing? Am I right? Please try to simplify what you are saying as it is not clear.

Mr.M 62

Do not post the same question on different forums while you are still getting response from the other forum just like how you did here.

Mr.M 62

Well I'm glad it worked. If your problem has been solved don't forget to mark the question as solved.

Mr.M 62

Well What I think you first need to do is that since you know your barcode try finding how many digits it has the for each textbox set its max to that value like if your barcode is 5 digits then set your text box's maxlenght to 5 then on the TextChange event insert an if statement to check if this textbox maxleght has been met or not, if the max is met then set the focus to the next textbox and so on to the end.

Mr.M 62

This is how I did it.

 Sub countR()
 ConnDB()
 Dim sql As String = "select COUNT (*) FROM register"
 Dim cmd As New OleDbCommand(sql, conn)
 dr = cmd.ExecuteReader()
 While (dr.Read())
 lblTotalR.Text = (dr(0).Tostring())
 End While
 End Sub

Mr.M 62

Which code part is highlighted during this error?

Mr.M 62

Well in your file you will need a separator that will separates the fields so that you will know how to identify fields(columns) in your text file. I will make an example of this. Since you said your text file will have 3 columns(Description, Part Number, Quantity) you need a way of separating this like this: sample|123|3 now in this example I used | as a separator and my code would be like this to read this text file, remember that you will read the fields into array.

 If My.Computer.FileSystem.FileExist("c:\test.txt") Then
 Dim sFile As String = IO.File.ReadAllText("C:\test.txt")
 ' The above will help to read all lines but will not be able to read or split each line, at least that what happened to me because of ReadAllText.
 Dim f As New System.IO.StreamReader("c:\test.txt")
 Dim lines() As String = Split(sFile, vbCrLf)
 For Each line As string In lines
 Dim x As String = f.ReadLine
 ' Now this is for giving the fields
 If x <> String.Empty Then
 Dim myArray(3) As String
 ' This is the array that will contain the fields
 Dim xz As String = x.Split("|")
 ' Now we split or form a field on this identifier |
 myArray = xz
 ' Now you can call or assign or do what ever you want with the data read. Suppose you had 3 text boxs.
 txtDescr.Text = myArray(0)
 txtPartNum.Text = myArray(1)
 txtQuant.Text = myArray(2)
 End If
 Next
 x.Close

That a sample of how to read the data and split it.

Mr.M 62

I think your computer is infected with a virus.

Mr.M 62

I think what you will need is something like this "For i As String = F To O" but not sure if it works with alphabets and a you can notice I didn't add the "Step" because I don't know how in alphabets but in numbers the step would be "1" or "-1".

Then in your code you would need to change "F" to "i".

Mr.M 62

Yes that's achievable, you will have to make sure you have used an extension that is not used by any file, since the sample I did bellow only checks and get a list of files but an extension. Also since you will be working with two extension you will have to code them separately one for extracting which will search for ".gov" and change it to ".sql".

Suppose your path is "D:\Test\" and you have more then one file inside. So you can do it like this:

 Dim D As DirectoryInfo = New DirectoryInfo("D:\Test\")
 For Each File As FileInfo In D.GetFiles("*.sql")
 Dim OriginalFileName As String
 OriginalFileName  = File        
 Dim result As String
 result = Path.ChangeExtension(OriginalFileName, ".gov")
 File.Move(OriginalFileName ,result)
 Next

Now you can use the very same code above for searching for ".gov" files to change them back to ".sql". Also note that you will have to swap around the extension to set it back to the original.

You can place the above code under a button to change extension, then copy it again and past it on the button to set to original and on the code just change the extensions.

HTH.

Mr.M 62

You can just hide the console instead. Use something like

 Proc.StartInfo.CreateNoWindow = True

Or but I'm not sure if it will apply, just before your essential information try hiding it using the bat code within your code you will do something like:

 Proc.Send {"The code to turn on the char hide here", "Enter"}

NOTE: not sure of the format but it must have or start with "Send" but the rest is like the above, and also note that at least for me when I used this method I had to close any on top app running like Task manager because these make the command prompt loose focus and the typing will be done on an on top app or app with focus.

This sends one commands to command at a time so you will have more commands.

Mr.M 62

Mmm the dropdownlist I think has some indexes which you can play around with to get what you want. But since you didn't say whether the selected year should remain the first selected even if the program restarts, and also you said you need to change the "default selected" I think you either want to re-arrange or want to just remember the selected value.

To do so you will need a global variable that will hold the selected value, but for your app to remember your choice you will need something to write your choice/selection(database/text file) at.

You can either keep/remember the index or the selected value, your choice.

 ' Suppose you want to keep the index. This is your global variable
 Dim SelectedIndx As Integer

Now you need to put this inside the dropdown selected item .

 SelectedIndx = DropDownList1.SelectedIndex

Now you will need 'IF' statement on your refresh to ensure the selected data remains selected.

 If SelectedIndx = Nothing Then
 ' Because we haven't saved any selected the default will apply.
 DropDownList1.SelectedIndex = 0
 Else
 ' We have stored something so let's replace default and use our own default selection based on what was selected.
 DropDownList1.SelectedIndex = SelectedIndx
 End If

Well there are some adjustments you will have to do, this is just an idea I thought while reading your post.

HIH.

Mr.M 62

If your question has been answered you can mark it as solved.

Mr.M 62

On your post you said you want to "CLEAR" but your code selects the first Item in your ComboBox.

Try

 ComboBox1.Text = ""

Mr.M 62

Yea or on ENTER keydown event which is not under textbox events but can be incorporated

Mr.M 62

Ow no you do it wrong. Let me differentiate these two tools for you so that you will see how its works.

1) Button -> has Click event which is to perform a task once the button is clicked.

2) TextBox -> has TextChange event which only take raise this event when/while typing something on it, this raise event for each stroke/character entered/typed or you can use it to track a typed word to see if its match/contains any word you want.

Now with that being said, the reason why I said you did it wrong reflect to this. The button does this for you so remove that code from TextChange event.

As I've said the textbox also allows you to monitor the word of which is what I think you want. In that case of yours to check the name if its exist while name is typed on textbox you need to use the sort of auto-complete or any other technique to tell if a name exist or not. To use auto-complete you will need to point its source to your database and keep in mind that if its does complete a word that means its exist.

Mr.M 62

Mr.M 62

A code will help so we can see how you ran it.

Mr.M 62

Ok, this worked to me, what I think you need to do is that instead of creating lots of IF statements without the ELSE could be the course why you don't receive this error message. Try to add the Else to your code like this:

 If radBusiness.Checked = False And radResidential.Checked = False Then
 REM: Do what you need here
 Else
 If radBusiness.Checked = True And lstConnection.SelectedIndex < 0 Then
 REM: Your current error that you say you don't receive here
 Else
 REM: Continue with your If Statement here, and so on keep applying the Else to a so common items conditions to the end and close all you if statements with End If
 End If
 End If

Please try that and see.

Mr.M 62

If your question has been answered please mark it as solved.

Mr.M 62

Try to make your variables as Global and see, also try to add another IF statement inside the current IF statement. The IF statement you need to add will be for checking if the dataread student number matches the student number supplied in a textbox if these match then populate data to textboxes or else just clear the textboxes that will ensure that its populates data based on the current entered student number on a textbox.

Mr.M 62

I think the problem is within your IF statement, will try this and hope I will manage to figure out the problem, because there is something I'm suspecting so just want to make sure of it.

Mr.M 62

I think maybe the command is too long so it need to cut the edges. I think it my also help if you could post the code as well.

Mr.M 62

Which error message doesn't display?

Mr.M 62

That's great. I think you may now mark this question as solved then.

Mr.M 62

Try this. You will have to change the naming. I have a Label which is Label2 which acts as a Total price or (Current Total) and I'm using ListView4.

 For Each iItem As ListViewItem In ListView4.SelectedItems
 ' I declared the variables I will use to keep track here.
 Dim Price_To_Deduct As Integer ' I used Integer because I didn't format the numbers to money format so you can try using Double but I haven't tested that.
 Dim Current_Total_Price As Integer ' This variable will contain the current total price which we will deduct from.
 Dim New_Total As Integer ' This will contain the new total.

 Price_To_Deduct = iItem.SubItems(1).Text
 Current_Total_Price = Label2.Text ' Retrieving the current total price so that we will do calculations.
 New_Total = Current_Total_Price - Price_To_Deduct
 ' Because I'm using a Label I now have to clear it and reUpdate it with the new total.
 Label2.Text = ""
 Label2.Text = New_Total
 Next

This should work.

Mr.M 62

@Dj yes I agree, I posted the use new line early then later when I was in front of my pc I then noticed that its not working. But I got your point there.

@Wishala you should have cleared that out, if so then you can use Dj's suggestion.

Mr.M 62

@DJ but there are situations where the items are retrieved somewhere maybe from a file or from a database then are added to a control, so I think we shouldn't stick much to the way of how the OP is adding because we may find that the data is retrieved some where else and it is dynamically updated so the OP may need to add it just like how he do, unless the data won't be updated at a later stage then the OP can add it internally or within IDE. Just saying

Mr.M 62

I've just worked with another project where the OP was also doing something similar except that, that's OP wanted to make more then one selections at the same time, as I worked with that's OP's question I noticed that even if you add the code for new line, the new line won't be added so I prefer you use ListBox instead of ListView, unless its a must do with a ListView.

ListView seemed to me that it had some limitations on doing things with it. With a ListBox what you require can be achieved so early.