i am reading a .txt file line by line.. adding each line in a listbox... but some characters do not show well in the listbox...
e.g.
in .txt file:
97 Jankulovski
98 Galásek
99 Poborský
100 Plasil
101 Rosický
but in listbox [see attachment]
i even used the forms 2.0 controls but still no good
btw: the .txt file i am reading is in UTF-8 ... when i convert to unicode..nothing shows up in vb... and when i convert it to ANSI... the accents are okay but some additional characters show up like "?????" or black boxes characters
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
Basically you use the replace() command to replace specific characters with more friendly characters...so you need to work out the characters you want to take out and what to replace them with :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
Basically you use the replace() command to replace specific characters with more friendly characters...so you need to work out the characters you want to take out and what to replace them with :-)
the problem for me is that the .txt file contain the names of football players and there are about 3200 players!!!! it will be hard to find out all the weird characters to remove!!!
edit: i have attached the text file.... there are square characters too.. the list is generated from a football game database....
Last edited by lplover2k; Jan 6th, 2007 at 03:46 PM.
the problem for me is that the .txt file contain the names of football players and there are about 3200 players!!!! it will be hard to find out all the weird characters to remove!!!
Doesn't matter how many players there are, there should be a limit to how many unique characters there are for you to replace. However, my suggestion is to try to find a better way to display them rather than filtering now...someone here must know a way to display non-standard characters in a listbox...have you tried using a listview or maybe a custom listbox designed with the intention of displaying non-standard characters, there MUST be one out there and someone'll link you to it :-)
I'd play about with it myself if I had VB installed...I recently reinstalled windows though and haven't got around to installing VB yet :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
You said earlier that the file is UTF-8...you tried converting to unicode then displaying in the UniListBox?
You might have to look into actually prefiltering (like I said before) and converting characters to valid unicode characters for it to display properly. It's not a problem I've had as I don't work with unicode data often and when I do it's not required that I display it in any way, so I am little or no use to you :-)
Edit: A tip for you...have a textbox on your form and have the name output to that textbox...then manually copy the 2 characters and use THAT in your manual replace...that should work fine :-)
Maybe make it so on mousedown on the listbox it puts that line into the textbox?
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
You said earlier that the file is UTF-8...you tried converting to unicode then displaying in the UniListBox?
You might have to look into actually prefiltering (like I said before) and converting characters to valid unicode characters for it to display properly. It's not a problem I've had as I don't work with unicode data often and when I do it's not required that I display it in any way, so I am little or no use to you :-)
Edit: A tip for you...have a textbox on your form and have the name output to that textbox...then manually copy the 2 characters and use THAT in your manual replace...that should work fine :-)
Maybe make it so on mousedown on the listbox it puts that line into the textbox?
lol isn't there a less time consuming solution?? i am desperate
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
The unorthodox methods (the ones I usually suggest and the ones that are for people who know of no orthodox methods :-)) are usually the best ones to go for...they do the job, albeit a weird way and possibly with extra work
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
The unorthodox methods (the ones I usually suggest and the ones that are for people who know of no orthodox methods :-)) are usually the best ones to go for...they do the job, albeit a weird way and possibly with extra work
yeah thanks but it takes lil more time for my listbox to fill up now... i have managed to filter almost all weird characters
some of the strings are not valid characters even in the text file
check lines 366 and 234
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
some of the strings are not valid characters even in the text file
check lines 366 and 234
an option
save the textfile as ansi, then just remove the question marks
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Does the actual data being loaded change regularly? If you use the same data, you might find it easier to filter and save it in word or something then load it already filtered into your listbox.
Does it even HAVE to be a listbox...if you're just displaying the info, you might find a richtextbox would work better :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
some of the strings are not valid characters even in the text file
check lines 366 and 234
an option
save the textfile as ansi, then just remove the question marks
That's a bad idea. Then any line with an "ä", for example, will turn into a bunch of question marks(just like every other foreign character would), and he won't know what to replace it with. All changes to any foreign characters should be assigned with a specific character 1-by-1, character-by-character. Otherwise you're screwed.
All changes to any foreign characters should be assigned with a specific character 1-by-1, character-by-character.
Not quite 1 by 1...if it *is* unicode or something similar you will probably find it's 2 by 1 (as the characters are stored using 2 bytes rather than 1) :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.