Use vb extended ascii

piero1975

Board Regular
Joined
Nov 20, 2002
Messages
56
I need to work with vb variables which contain some extended characters (such as "£" , "ç " and others). But I think VB Excel doesn't manipulate this chars correctly : when I control their value, the char I display are ‡ , spaces, etc.

Is there any way I can use an extended characterset ? Have i to use a particular kind of declaration of my variables?
Please help.
Thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
zilpher said:
can you post some code please, don't understand your question

Z

i.e. :

i read a string variable "VAR_file" within a txt file.
The string is "01çTSZPT"
but visual basic read it in this way :

"01‡TSZCP"...an so my procedure doesn'work properly.

I'm getting this problem with some others chars...

truly I don't know. I think this could be solved if I can set VB to use another char-set (maybe extended.....).


Tanks
 
Upvote 0
I used your string in a very simplistic example and had no issues:

Private Sub CommandButton1_Click()
Open "c:\c.txt" For Input As #1

Line Input #1, e

Close #1

MsgBox e

End Sub


Text file contains: 01çTSZPT

How are you opening and reading the file? What version of Excel, OS are you using? What language is your system using?

Sorry for all the questions

Z
 
Upvote 0
zilpher said:
I used your string in a very simplistic example and had no issues:

Private Sub CommandButton1_Click()
Open "c:\c.txt" For Input As #1

Line Input #1, e

Close #1

MsgBox e

End Sub


Text file contains: 01çTSZPT

How are you opening and reading the file? What version of Excel, OS are you using? What language is your system using?

Sorry for all the questions

Z

I've opened a file in both of "for binary" and "for input" mode.

I've declared the variables as string...maybe this is the problem?

I'm using Excel 2000 under Windows NT;the regional settings of my system are "synchronized" with my Excel version.

Thank in advance
 
Upvote 0
Can you post the actual VB you are using? A section of the text file would be handy too.

Declaring your variables as strings won't be an issue, I cannot make this error on my machine and suspect either the file or the method used to open and read the file.

Z
 
Upvote 0
'This is the section :

intFile = FreeFile()
myvar = String(10, " ")

While Not IsEmpty(Range("A" & counter))
Open "c:\input.txt" For Binary Access Read As #intFile Len = 10

While Not EOF(intFile)
Get #intFile, , myvar()
MsgBox myvar
If (Trim(Range("A" & counter).Value) = Trim(Mid(myvar, 1, 8))) Then
'make something
End If
Wend
counter = counter + 1
Close #intFile
Wend

'This works fine with an input that not contains any strange char.

'This is a section of the input file
....
01ºTSZ
01ºTSZPT
01þTSZCP
01þTSZPT
....

Thnaks
 
Upvote 0
I've tried every which way I can but I cannot make this fail, although using Get in your code did produce erratic results. I suggest you use Line Input instead of Get, IIRC Get will read the whole file and might be having issues with the characters to which you refer.

Try this code, a mod of your own:

Private Sub CommandButton1_Click()
intFile = FreeFile()
'myvar = String(10, " ")
Dim myvar As String
counter = 1
Open "c:\c.txt" For Input As #intFile
While Not IsEmpty(Range("A" & counter))

While Not EOF(intFile)
Line Input #intFile, myvar
MsgBox myvar
If (Trim(Range("A" & counter).Value) = Trim(Mid(myvar, 1, 8))) Then
'make something
End If
Wend
counter = counter + 1

Wend
Close #intFile
End Sub

If that doesn't work then I'm out of ideas as I can't get this to error in the way you describe.

HTH

Z
 
Upvote 0

Forum statistics

Threads
1,225,814
Messages
6,187,180
Members
453,411
Latest member
healthcares

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top