Mr.M 89 Future Programmers

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 89 Future Programmers

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 89 Future Programmers

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 89 Future Programmers

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

Mr.M 89 Future Programmers

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 89 Future Programmers

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
Tafadzwa_3 commented: Where is dr declared and how do you delcare dr +0
Mr.M 89 Future Programmers

Which code part is highlighted during this error?

Mr.M 89 Future Programmers

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 89 Future Programmers

I think your computer is infected with a virus.

Mr.M 89 Future Programmers

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 89 Future Programmers

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 89 Future Programmers

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 89 Future Programmers

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 89 Future Programmers

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

Mr.M 89 Future Programmers

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

Try

 ComboBox1.Text = ""
Mr.M 89 Future Programmers

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

Mr.M 89 Future Programmers

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 89 Future Programmers
Mr.M 89 Future Programmers

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

Mr.M 89 Future Programmers

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 89 Future Programmers

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

Mr.M 89 Future Programmers

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 89 Future Programmers

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 89 Future Programmers

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 89 Future Programmers

Which error message doesn't display?

Mr.M 89 Future Programmers

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

Mr.M 89 Future Programmers

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 89 Future Programmers

@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 89 Future Programmers

@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 89 Future Programmers

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.

Mr.M 89 Future Programmers

An example based on your above code will be:

 List1 = Me.lsv1.Items.Add(Me.txtDescription.Text & Vb.NewLine)
 List1 = Me.lsv1.Items.Add(Me.txtPrice.Text & Vb.NewLine)

Something like this should help do what you intend to do.

Mr.M 89 Future Programmers

You need to add

 &VbNewLine

at the end of the add statement so that when you click twice it will write the data on a new line below the previously added data.

Mr.M 89 Future Programmers

Don't forget, if your question has been answered to mark it as solved.

Mr.M 89 Future Programmers

The above is one URL address, it also have a very good example of how to use it.

Mr.M 89 Future Programmers
Mr.M 89 Future Programmers

WebClient.DownloadFile seem to be easy to work with, have a look at it.

stackoverflow.com/questions/4066082/download-file-in-vb-net-2010

Mr.M 89 Future Programmers

This could be done by to many lost packets, or the way you receive and write the downloaded bytes so it would help if you can post your code here so that we can see and help you out.

Mr.M 89 Future Programmers

Are you sure the server you are trying to connect to is up and running? Also the server name are you sure matches with the name you entered? Is the server accessible?

Please try verifying these because the error says the server is not found, it can be one of these things that may result to this.

Mr.M 89 Future Programmers

Does the user have a place where s/he will enter the address or the browser retrieve the URL somewhere? If the user is the one entering the URL then you can simply check the entered address and if its youtube address then instruct WebBrowser to browse to that other address.

Also please capture and post here the error so we can see, also another thing is that before you can start doing anything with WebBrowser you need to start by this code:

  On Error Resume Next

  ' This should solve your problem.
  If WebBrowser1.Url.PathAndQuery.Equals("http://www.youtube.com") Then
 ' MsgBox("You have entered youtube website.")
 WebBrowser1.Navigate("http://www.google.com")
 Else
 ' MsgBox("Other address entered")
 End If

Hope that will answer your question.

Mr.M 89 Future Programmers

Also check this solution here.

 visualbasic.ittoolbox.com/groups/technical-functional/vb-dotnet-l/insert-data-into-an-sql-express-db-from-vbnet-form-5240174
Mr.M 89 Future Programmers

I agree with @Sanu

Mr.M 89 Future Programmers

You need to use Stream as @Jim has said. Check out this good example I found it here:

 net-informations.com/vbprj/dataset/retrieve-image.htm

And here is a step by step guide too:

 support.microsoft.com/kb/321900
Mr.M 89 Future Programmers

Simply Declare

 Dim count As Integer

As global variable then under the buttonClick event handler at the very beginning of it add this.

 count = count +1
 lblDisplay.Text = count

That will keep on adding the number as you click the button starting from 0 upwards.

NOTE when you terminate the program and start again the count will also start afresh to keep the count going don't close the program.

Hope that answer your question.

Mr.M 89 Future Programmers

If you have found solution you need to mark the post as Solved.

Mr.M 89 Future Programmers

I think your problem here is that Timer3 hasn't been called to start ticking. What I think you need to do is on the first form load place e.g. (Timer1.Stat()) to start timer1 then maybe on timer1 you can start the second timer and ensure that you stop timer1 and on timer2 you start the third timer and also ensure you stop timer2 and finally on timer3 you can leave your codes as is and also do stop timer3 after firing the events. You need to make is sort of a chain.

Mr.M 89 Future Programmers

Please provide with detailed info as Jim has said and also I don't think a program is capable of doing anything after stop debugging what I think you mean is "On Form Exit" which the code placed here are always executed before the program stop debugging or fully terminate or exit.

Also your codes are in a form of a poor programming as you didn't label the buttons accordingly for easy referral (so that we can see that this code is for this without having to read the entire code to see what is it for, and also no comments.

Try also to familiarize your self with those things they event help you easily spot the codes.

Mr.M 89 Future Programmers

@ddanbe what I think is the problem here is the he is using a timer and a timer's interval is in its default values which result in it to execute more then one time, I noticed this when I've applied a Stop call below the MgsBox so that it will display the message and stop but it displayed more then one message before stopping so what I did was that I adjusted the interval to give it enough time to fire perform the task because when you give the timer enough time to pass it can read codes correctly and fire events in a correct way.

The smaller interval value is supplied the more repetition of events. The higher the values the less repetition of events.

Mr.M 89 Future Programmers

Ok I've just tested this and got the solution,
Firstly start by increasing the timer interval to "1000" then
Secondly add the Stop call to your code as I've told you on my first post and debug. To play around with this change the interval to 500 and it will open your app twice but when increasing the interval 2x then the timer read once code and stop.

 If TimeOfDay = "08:30:00 AM" Then
 MsgBox("Testing")
 Timer1.Stop()
 End If

Remember to adjust the timers interval on timer properties to 1000.
Hope this answer the question.

Mr.M 89 Future Programmers

What you need to do is stop the timer bellow your expression of opening a program

 Timer1.Stop()

This will stop timer from ticking

Mr.M 89 Future Programmers

Remember if your question is answered you must mark it answered.