Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Writing Double Byte Characters Into Ascii File


I need to write some text string reading from a database into ascii file. The string could be a mix of English and double byte characters like Japanese etc.

Can I write in the following way (sequential file type)

Open FileName For Append As #1
Print #1, text
Close #1

or do I need to open a binary file for writing??


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Handling Double Byte Characters In ASCII File

Sorry for shootting questions again on double byte character set. I'm writing an application for extracting data from SQL server and writing into ascii files. The application is written in VB and would run in multiple countries like Japan, china etc. I've no issues with countries which have all their data in English. The application will be running on the respective regional Windows Operating system of countries. When running for Japan, the double byte characters are written properly in the respective positions in the ASCII file meaning if column positions 1-10 are for name, then I can see 10 Japanese characters. ( This holds good even if the charcaters are a mix of English and Japanese). When I open this file in any Windows system with default Japanese code page, then col 1-10 would display these charcaters properly. But if I open the same file with default code page as English, then this would actually take 20 column positions if all the characters are Japanese(every charcater is split into 2 positions and the characters appear as garbage). The destiantion program reads and interprets the files based on the column positions and because of the double byte split , the destination program can not get the correct values . Moreover the destination program is running on a Unix machine and it receives feeds from multiple countries. So when it expects col 1-10 as Name, 11-20 as ID, works fine if all the characters are english, but if is a double byte , then column positions would have shifted because of the double byte split and it cannot interpret values properly. Can any one help me in handling this?

Thanks in Advance


Help Required. Writing Unicode Characters Into Ascii File
Hi ,

I need a help in handling double byte characters( Japanese, Chinese kanji characters) and writing into an Ascii file.
My requirement is to write data into the file in fixed positions., Eg. col 1-40 will have one value, 41-72 will have another value and so on. The column positions are fixed for each value. If the value doesn't occupy the entire column width, then it has to be filled with blank spaces. For eg., if the col1 value is "Hello" then the remaining 35 positions will be filled with blank spaces.

Now suppose I write a Chinese/japanese character, then every character being a double byte character, it is supposed to occupy 2 positions. Suppose a string has 5 double bytes, then it is supposed to occupy 10 column positions in ascii file. Now because the col1 width is 40 , now I'm supposed to add only 30 blank spaces, otherwise it'll spill over into the next column.

( If the file opened with a proper code page , then it will show the actual characters, but if it is opened with a English code page, then you'll actually see these characters occupying 10 positions but all of them appear as junk.)

So in my VB code, I'm currently doing this:
First convert string into byte array,
Loop over byte array, and check if the character is a double byte or not.

(Because VB stores all characters as unicode, byte array would occupy the double the size of a string.
So if the character is a double byte, then both b(0) and b(1) to have value greater than 0.
If the character is a Ascii, then b(0) will have value greater than 0, but b(1) will be 0.
I checked the AscW value for these characters, some are greater than 255 and some have negative values also.)

b = myStr

For i = 0 To UBound(b) Step 2

If b(i + 1) <> 0 Then'Implies double byte character
NoOfDoubleByte = NoOfDoubleByte + 1
End If


then based on the no. of double bytes, reconstruct the string with appropriate no. of spaces.
Suppose the string is supposed to occupy positions 1-40, then decrement the No of double bytes in the string and add that many spaces.

mystr = mystr & space$(40-(len(mystr + NoOfDoubleByte ))

Then finally write this into an ascii file.

Open FileName For Append As #intFile
Print #intFile, myStr

Now the problem.
The logic appeared to work fine so far. But suddenly I find that there are some Japanese characters, though being double byte is appeared to occupy only one position,. ( When opened in note pad with a English code page , a few charaters have occupied 2 positions , but a few of them have occupied only one position.)
so this entire logic of building string has gone haywire. Can some one direct me to the correct way of handling this.

Any help is highly appreciated.



Double Byte Characters In VB
Hi All,

Is there any way to restrict the text in a VB text box to only single byte characters, so that the user is not able to enter any double byte characters.

This is very urgent.
Please help.

Thanks in advance.

The Beret

Sending Double Byte Characters Over RS232 Using In VB

I have a console C++ app that send a character over a Comm port without a problem, the characters for instance in hex are 0x90 also any character I assume in the unicode range, but when I try to send a character in this range using VB and the CHR() function I get a message "runtime error5 invalid procedure call, it seems if as if the CHR() function cannot convert value greater than 255,
In the help file it mentions something about DBCS systems and there ability to operate in the range of -32768 to 65535, is there a work around that anybody has doen to overcome this limitation and does anybody know how to enable DBCS on Windows 2k (if that solves the problem)

Thanks very much


Adding A Line That Contains Double Quotes To An ASCII File
Good Afternoon,
I need to add a lines to a ASCII file that have " in them. Is there a way of getting these lines in there?

Here is an example:

'sFileName comes into this sub from the main procedure!
Dim FSO As New FileSystemObject
Dim TS As TextStream
Set TS = FSO.OpenTextFile(sFileName, ForAppending)
TS.WriteLine "version="1.0""

Obviously that last line doesnt work, but is there a workaround?

The file is read by another application and it requires the 1.0 to be surrounded by quotes.

Any help is extremly appreciated.


How To Read Data From A File When The File Has 2 Byte Characters (UNICODE)?????
I want to read data from a file in which data is written in 2-byte characters (unicode). Actually i want to make a control that reads data from a file and writes the corresponding integer value (2-byte) to another file. This is easy in Visual C++ environment but in VB i am stuck. please help. I have very little time left to complete the task.

thanks in advance

Open File With Non-ascii Characters
Dear All,,

Can anybody help me to read this textfile (.txt).
The file contains of 7 lines and 2 columns of data in wich are separated by a [Tab] ,,

Server IP        Username
----------------    -----------    acmog    nlt    AQHa>W    +A+P    hodoncw    mumin    dhogorcad    

my problem is: when i wanna count total lines of a text file it returns only 4 instead of 7 becouse it terminates on (+A+P)
where unwanted characters are included. so please help me.

i have used the following lines of code to get it.

   Dim iCount As Integer, LineData as String
   Open FileName For Input As #1
   Do While Not EOF(1)

      Line Input #1, LineData
      iCount = iCount + 1

Thanks for your help..

Edited by - AbbydonKrafts on 5/26/2007 6:45:48 PM

Writing To A File's Specific Byte
Hey, i am trying to write to a specific file with this code, but the file i'm creating simply does not ever actually create itself!!
VB Code:
For i = 1 To FilesLen - 1 Step 1 '... this is meanignless part of the code Put #2, i, CurByte Next

Removing Strange Characters From A Csv Ascii File
I need to write a small prog that will simply remove certain characters from a csv ascii file. The file is for a register that we use in our school.

Every now and then, for some reason, strange characters appear in the file and thus the registers are all wrong. the ascii value of the characters that appear is 221 i believe.

I just need to write a prog that will search through and remove just these randomly placed characters. I say random, they always appear at the beggining of the line of characters.

Any help would be great



Writing Bytes From A Byte Array To A File.
Hi, I'm using VB6 and I'm trying to byte flip parts of a file. So far I've got the source file opening into a byte array and I've got the code to save the flipped bytes to the destination file sorted, but heres my problem, when I save the flipped bytes to a file each byte is either preceded or followed by 1100.

Source - play = 706C 6179
Destination - p..l..ay.. = 7011 006C 1100 6179 1100


Opening the files

Fno = FreeFile
Open OpenMeta.FileName For Binary As Fno
Tag = FreeFile
Open SaveTag.FileName For Binary As Tag
SizeOfFile = LOF(Fno)
ReDim Bytearray(0 To SizeOfFile - 1) As Byte
Get #Fno, , Bytearray

tmp1 = Bytearray(sbyte + 0)
tmp2 = Bytearray(sbyte + 1)
tmp3 = Bytearray(sbyte + 2)
tmp4 = Bytearray(sbyte + 3)
Put (Tag), , tmp4
Put (Tag), , tmp3
Put (Tag), , tmp2
Put (Tag), , tmp1
Where tmp1/2/3/4 are bytes and sbyte is the byte array offset.
I'm learning this stuff as i go along so any help is appreciated.


Ftp Command To Set Byte Position In File For WRITING
I've posted the same question and luckily I got the answer.
But now I got another problem.
As most of you know, you can set byte position for reading in ftp,
but how about setting it for writing? Possible? and how?

Thanx a lot

Writing Into An ASCII File (2 Questions)
1. How do I write into an ASCII file and how I can count the lines that the file contains.?
2. How do I find and specific line into the ASCII looking for an specific key.?

Need Help In Writing And Reading Chinese And Korean Characters Into/from A .txt File
Hi ,

I use Windows 2000 Professional English OS and Visual Studio 6.0 (English version) for development.
I have to pass strings from VB application to VC dlls and get strings back from the VC dlls to VB application.
These strings can be Japanese , Chinese , Korean.
1. I set all the Locales default to Japanese and had the default IME version as Japanese in the control panel settings. Restarted my machine. Using charmap , I copied a Japanese text and pasted in the VB text box and passed the text to the VC dll which uses _tfopen , _fputts to write the Japanese input string into a .txt file. The VC dll uses _tfopen and fgetts to get the Japanese string from the same file and appends a string _T(" : Output") to the string read from the file and sends it back to the VB application. The VB application displays the string from the VC dll in another text box. When I open the file using Notepad , I see Japanese characters in the file and when I go to the menu option Save As in the notepad , I see the current file to be of type Unicode.
2. I seem to have successfully passed the Japanese characters from VB to VC . But I am unsuccessful in passing Chinese and Korean strings from VB to VC. I made the appropriate Locale settings and the IME settings for chinese and korean and restarted the machine. But the file created by the VC dll does not have the input I passed to it. It either has ???? or some other characters other than the ones I passed. Could anyone help on what should be the settings on the VB , VC and the system settings for me to pass Chinese and Korean characters from VB to VC and to write correctly the Chinese and Korean characters properly into the file by a VC dll.
3. Though I seem to have successfully passed on the Japanese characters from VB to VC , I still do not know what are the basic requirements for this to be successful. So it would be helpful if some one could tell me the settings for VB , VC and system for passing Japanese characters from VB to VC and to write correctly the Japanese characters properly into the file by a VC dll


Back With Another Stupid Question.. Writing Characters To Data File
hey guys, im back again with another question...
ok, heres the deal. i have a loop that gets a character from another part of my program(it is a different character each time) and writes that character to a data file. the problem is, that it writes each character on a new line. this doesnt have much effect on the functionality of my program, but for ease of reading, i would like to have the data file more orderly when i go to read it.

here is what i had

Open "output.txt" For Append As #1
Write #1, letter(i)
Close #1

but now, i just have it so each character is added to a string and when the string reaches a length of 30 characters it writes the whole string to file

or another idea i have.. is it possible to start adding characters to a string,
and if there is a gap of more than 5 seconds in between the addition of a character to the string then write the string to a file

maybe i am thinking too much, theres probably an easier way that im not seeing. sorry if this seems over-complicated i explained it best as i can...
thanks again =)

How Can You Convert URL Characters To Ascii Characters? (ie %2F = /, %3A = :, Etc)
Anyone have a function that can take a string and return its normal characters?

Double Byte?
Hi all!

I'm using this code, but is there a way to double the size of a byte? (so: 2 bytes)

Private Type DataRead
leagueid As Byte
space1 As Byte
teamid As Byte
space2 As Byte
End Type

Have been searching on the forums and MSDN, but couldn't find anything. I want something to read leagueid and space1 in one thing. In my hex editor the value is "3203", but when reading teamid out of the file it only gives the first part "32".

0100 0000 0D01 0000
0100 0000 0F01 0000
0100 0000 1001 0000
0100 0000 3203 0000
0100 0000 3303 0000
0100 0000 3403 0000
0100 0000 3A03 0000
0100 0000 A205 0000
0100 0000 A305 0000
0100 0000 A505 0000
0100 0000 EC05 0000
0100 0000 FC06 0000
Sorry for my poor English, but what I want is this:
- first column = leagueid
- second column (0000) = space1
- third column = teamid
- fourth column = space2

Greetings and thanks in advance!

Get Byte From Double Value
Hello Everybody,
    I have one double value. From that double value i want to get byte by byte data. but when i tried to do it it is giving me overflow error? is any body know How to do that??

for example
dim dblval as double
dim bytval as byte

bytval= dblval and 255
it is giving me overflow error at this point.
Reply me ASAP.

Byte Arrays To Double
How would you take 8 elements of an byte array and place them in a double datatype.

I have 8 elements of a byte array from a telemetry packet that make a whole double not sure how to combine them.


Double-byte Languages
Can VB6 show captions and menus for "double-byte languages" such as Chinese, Japanese etc?

Double Byte Character
I am looking for some VB example on Double byte character (Not Unicode) for international language. Are there any good site?


Byte() Buffer To Double
Here is the byte() buffer that I have:

byte(0) = 0xDB
byte(1) = 0xDD
byte(2) = 0X6C
byte(3) = 0x0A
byte(4) = 0x3A
byte(5) = 0xC6
byte(6) = 0xE6
byte(7) = 0x3F

Need to convert this byte buffer into a 64 bit ANSI/IEEE std 754 IEEE floating point number

Anyone out there no how to do this???

Reading Ascii From Byte Val
I need to be able to read a an array of Byte values from a file and convert it to 7 bit ascii.

Eg, I read byte offset "2345" and it returns 58. How do make an array to hold values in then convert them to ascii.

Btw, I'm reading a TIFF file and am trying to read a tag called "Description".


Dir$ And Double-Byte Character Filenames

I am doing a recursive search of folders and files (that thing that I picked up here is brilliant! Thank you )... but I have some Japanese files and folders. It gives me an "Invalid Filename" runtime error when I run the program.

Any ideas/thoughts?

Thanks in advance.


Double Byte Codes In Excel
I have a spreadsheet with mandarin characters in it. These characters (words) are stored as double byte binary codes. I want to retrieve these codes in thier raw format.

Every attempt I have tried so far has seen them be converted to ascii text.

Please help.


Double-Byte Encoding Conversion
I'm currently in the middle of building a multi-language software which communicates with a machine which spits out data (in bytes) through USB port.

To process the data, I need to convert the data to char type. It seems like the value that I'm getting when using Windows XP with the regional settings set to English is different when I set it to Chinese(traditional).

I've searched the web and I found out that the 2 languages using different encodings (chinese using double byte encoding where 2 bytes represents 1 characters while english use one byte to represent 1 characters).

Is there anyone knows how to convert between the 2 encodings in Visual Basic 6 or have different approach how to get the same value from the 2 encodings? Thanks.

Byte Swap Little Endian To Double
I have a 8 byte buffer and I need to convert it to a "Double". It's in little endian format. I need to know how to convert it using 8 bytes. I NEED HELP!!!

Byte To String Conversion (ASCII)
I'm trying to convert a database retreived data (data is stored in image data type i.e. byte) into its corresponding ASCII based text (string). I have the following code working however, when it takes an awful long time to convert. A 30 recordset takes approximately 40 seconds to complete. And since I have recordsets that go as high as 115000 records, I think my approach is not efficient. I have also noticed that a null character (ASCII 1-31) take a lot longer to write to a file compared to if I strip them off before writing.

Can someone help me steamline this please? Here is the code snippet:

(Assume that all database related variables have been declared)

   Dim bPages() As Byte
   Dim str as String
   Dim fs As TextWriter
   fs = File.CreateText(path)

   While rdr.Read()
    bPages = rdr("DisplayData")

    For i As Integer = 0 To bPages.Length - 1
     If CType(bPages(i), Byte).ToString = 255 Then
      str &= ControlChars.NewLine
       str = System.Text.Encoding.Default.GetString(bPages, i, 1)
     End If

   End While

Sample byte data from the db (one lone line; output is wrapped):


Edited by - zsyed on 3/10/2006 9:27:42 AM

Double-byte Chars In Word Macro(?)
I'm not sure which forum i should ask this question in, but here goes. You'll probably wonder why I need to know this, it's to write the VB portion of a camputer-aided translation program.

Anyway, I'm working on a macro in Word which reads a Word file line by line and write it to a text file. Simple enough, until I had to use it on files written in Chinese. Then I started getting error messages.

Anybody know how to enable VB to output double-byte strings in Asian langs? Microsoft says that VB can't do this but hints that there are some workarounds. I've considered their IPDK but don't know if that does it.

Here is some sample code:

Sub Chi2TXT() ' not real name

Dim fso, txtfil, chidir, unidir, chichar, unichar
chidir = InputBox("Please type the full path and filename of the TXT output file", "Enter Glossary Path and Filename", "c:"

Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfil = fso.OpenTextFile(chidir, 2, True)
Selection.HomeKey Unit:=wdStory, Extend:=wdMove

x = 0
y = ActiveDocument.BuiltInDocumentProperties("Number of Lines")

Do Until x = y 'do as many times as there are lines in the active doc
Selection.Expand Unit:=wdLine
chiline = Selection

uniline = StrConv(chiline, vbUnicode, [LocaleID])
'little help with LocaleID? Don't know which to use.

x = x + 1
txtfil.Write (uniline)
txtfil.WriteLine ""
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdMove

End Sub

Simple enough. I don;t use WriteLine to write UNILINE because it turns the chinese back to ANSI format. But when I do use it to insert a paragraph mark it displays that mark as a strange Unicode char (at the beginning of each line except the first) which messes up the display. If I eliminate it, the rest displays correctly.

But is there a way to FULLY enable VB to work with double-byte so I can stop doing all these tricks? I need to make other macros and this workaround might not solve all my problems.

Does VB 6 Support Double Byte Asian Languages?

I have a scenario that I'm hoping to see if anyone has come across this. Basically, we wrote an app in VB6 at work. Everything had been tested in regular English Win XP and Vista and confirmed that it's working fine. This app was then installed in Korea, with the Korean version of Windows OS. It was just reported to us that it's not working at all.

Well to make it short, in our code, we have to communicate to a proprietary USB device. The USB communication chip that we purchased retrieves the input buffer from the USB port as a type string. We then depend on the ASC() function and Chr() in VB 6 a lot to do the parsing of the input buffer. Well, ASC() and Chr() work fine in single byte languages, but we just confirmed that they do not work for double byte asian languages, in this case Korean.

Has any one here come across this problem in the past? The thing that I can't understand is that for example: a character of ASCII code 128, if you run this through the ASC() function, in single byte language systems, it should give you back the value of 128. However, I have noticed that in a double byte language system, it gave me a really strange value of -23834. How can this happen?

If you have any thoughts on this, I really appreciate your help.

Thank you.

Taking Double-Byte Into VB 6 Then Back Out Into SQL Server
I'm trying to take Excel spreadsheets with data in a few different languages (English and Japanese at least), read, parse, and error check them in VB 6, then write to SQL Server 2000 in unicode (to support double-byte characters). However, I am having issues pulling in double-byte from the spreadsheets into VB 6 and having VB recognize the characters (it currently displays question marks). I've looked at the knowledge base and can see that controls can be used for allowing double-byte entry into a VB app and handling it, however my app should run behind the scenes to just process files and will need no controls such as textboxes. Does anyone have any ideas of how I can do this? Right now, I'm developing on Windows 2000, and have loaded the Japanese language pack to no avail.


Can You Do The Reverse Conversion Of 8 Byte Array -&gt; Vba Double.

I have a function which converts an 8 byte array (read in from a cobol program) into a double value in VBA. It works.

Do you know how to do the reverse, i.e. take a VB value and convert it into the 8 byte array representation?

I am stumped. Any hints you may have would be greatly appreciated.

Pin Suew

Here is the function which converts 8 byte array into a double value.

Function cv8ByteArrayToDouble(Bytes As Variant, ByRef d As Double) As Boolean
' Please note - bytes are number 1 - 8 and bits in each byte start at 1 and go to 8.
Dim dImpliedMantissa As Double
Dim lBiasedExponent As Long
Dim lSignOfMantissa As Long

If (Not UBound(Bytes) - LBound(Bytes) + 1) = 8 Then
GoTo ErrHandler
End If

dImpliedMantissa = 0
lBiasedExponent = 0
lSignOfMantissa = 1 ' Assuming bit in 64th position is 0 (and SignOfMantissa of ImpliedMantissa is positive)
cv8ByteArrayToDouble = True

' (A) Check if ImpliedMantissa is negative
If (Bytes(1) And CByte(128)) > 0 Then
lSignOfMantissa = -1
End If
' Debug.Print "Sign of Implied Mantissa: " & lSignOfMantissa

' (B) Get the value of the BiasedExponent (valueofbits-fixed value of 1023)
' Start at bit 5 of bytes(2) and goto bit 7 of bytes(1)
Dim lByteCtr As Long
Dim lByteFrom As Long
For lByteCtr = 5 To 8
If (CByte((2 ^ (lByteCtr - 1))) And Bytes(2)) > 0 Then
lBiasedExponent = lBiasedExponent + 2 ^ (lByteCtr - 5)
End If
Next lByteCtr
For lByteCtr = 1 To 7
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(1)) > 0 Then
lBiasedExponent = lBiasedExponent + 2 ^ (lByteCtr + 3)
End If
Next lByteCtr
lBiasedExponent = lBiasedExponent - 1023
' Debug.Print "Biased Exponent: " & lBiasedExponent
' (C) Get the value of the Implied Mantissa (1+(Value of binary fraction))
For lByteCtr = 4 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(2)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr - 4)))
End If
Next lByteCtr
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(3)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 4)))
End If
Next lByteCtr
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(4)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 12)))
End If
Next lByteCtr
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(5)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 20)))
End If
Next lByteCtr
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(6)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 28)))
End If
Next lByteCtr
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(7)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 36)))
End If
Next lByteCtr
For lByteCtr = 8 To 1 Step -1
If (CByte(2 ^ (lByteCtr - 1)) And Bytes(8)) > 0 Then
dImpliedMantissa = dImpliedMantissa + (1 / (2 ^ (9 - lByteCtr + 44)))
End If
Next lByteCtr
dImpliedMantissa = 1 + dImpliedMantissa
' Debug.Print "Implied Mantissa: " & dImpliedMantissa
' Debug.Print StrConv(dImpliedMantissa, vbUnicode)

d = lSignOfMantissa * dImpliedMantissa * (2 ^ lBiasedExponent)
Exit Function
cv8ByteArrayToDouble = False
d = 0 ' 0 vallue
End Function

How Do You Byte Stuff Characters
I am creating an email server and I wanted to know how to byte stuff an character and what is the meaning of this.
Thank You

High Speed Finding Strings, INCLUDING Double-byte Chars
I need to write a module that its function is to find strings in another string incluing double-byte characters. This is very important!!! Because I had tried the SendMessage with EM_FINDTEXT & EM_FINDTEXTEX and it runs, but it couldn't find double-byte characters in Win98 but WinNT. So I need a solution to solve this problem. Find double-byte characters both in Win98 and WinNT.Of course, I need it to find in very large text and has very high speed. Who can help me, Thank you very much!!!

Ascii To Characters
ok i know how to convet a character to a decimal number from the ascii code but how do u go back the other way

EX. if i have 97 it changes it to 'a'
any help will be greatly appreciated

Help Re Double Quote Characters?
When I edit a Visual Basic source file in Notepad or WORD. then use the file in Visual basic...the quotes that I type from keyboard, do not work in a text string.
Very confusing. These quotes do work in other parts of the source.

Ascii Code Into Characters
Hey all.
i am an UBER n00b at this site and to Visual Basic. Currently i am taking a visual basc class at school but that leaves a LOT to be desired. ok here is my delima, don't laugh, its extremely n00bish:

I have a program to take a string and display it in its ascii code. This part was fairly easy but now i want to have the program convert a string of ascii code into characters forming a message. This is the code for the encoding part of my prog:

Private Sub optEncode_Click()
Dim strMessage As String
Dim I As Integer 'index for next loop statement
Dim strChar As String
Dim strAscii As String 'the ascii code to be displayed
Dim intLen As Integer 'number of characters

strMessage = InputBox("Enter message for encoding", "Please Type Message")
intLen = Len(strMessage)
For I = 1 To intLen
strChar = Mid(strMessage, I, 1)
strAscii = strAscii & " " & Asc(strChar)
Next I
lblDisplay.Caption = strAscii

End Sub

Pretty straight forward. i want to use a similar code to "decode" ascii the problem is i don't know how i would distinguish between character codes within the string as some are 2 digit and other 3, etc. Pleaze help this n00b!

Special ASCII Characters
Hi All!
How Can i use special character like ALT + 255 in my code??
i want to write to .ini file like [ALT+255] & BlahBLah how can i do this?

plz help

Iterating Over ASCII Characters

I want to use a for loop that iterates through the ASCII chars.

in c/c++ you can do this.

char asciichar = 'A';
for(int i = 0; i < 25; i++)

At the end, asciichar = 'Z'

Any help appreciated...TIA

Convert Characters To Ascii No.
i have an array called chars(). when my program runs, 1 character is stored in each variable of the array eg. chars (0) stores 1 character, chars(1) stores 1 character and so on. i heard that there are 256 ascii characters, is there a simple and fast way to convert each character into its ascii number, say chars(0) had the letter u stored in it and the number of u was 132 then chars(0) would be changed to 132

ASCII Special Characters
I am working on a text editor which will allow my wife to write text in a language other than English (French and Spanish specifically). I want to make a series of buttons which will input one of the accented letters into the text box. How can I render a special character by simply clicking a button? I know what the codes are to create these characters in Word. Can I use the same codes?

ASCII To Actual Characters
Dim integer s
s = 65

This will display 65, obviously. How do I get it to display "a" (65 is the ASCII code for a.


Checking For Non ASCII Characters

How would I be able to parse a file and check for non ASCII characters?? I want to parse files that come from a mainframe to ensure that there are all ASCII characters in them.

Any help would be appreciated.

Characters For ASCII Codes
I am trying to print out the characters for the numeric ASCII codes (e.g., 65 = 'A') It is printing out the numbers but not the letters. I don't know what I am doing wrong...Here is my code:

Dim i As Integer
For i = 65 To 90
Chr$ (i)
Print i
Next i

Are ASCII Characters 128-255 Used In Files?
Just wondering (actually I kind of have a reason) if those characters are used or it's just the first 128. Also, ASCII 0 is nothing, right? If so, why would anybody use it? Is A = Chr$(1) & Chr$(0) & Chr$(1) the same thing as A = Chr$(1) & Chr$(1)

Where Is The List Of ASCII Characters?
I'm not sure that's how I should have worded the subject- I want to know what all the different Chr$(whatevers) are, how many of them there are (I'm guessing 255), and what different combinations there are. Or are there any true combinations? VbCrLF is supposedly chr$(13) + chr$(10) but is that really a combination or is just a way of saying vbCR and then vbLf? Babble babble babble, thanks for any help.

Ascii Characters In Strings
I am new and need some help with trying to pick off a set of double quotes in a string. I know that I have to use the ascii equivilent, but I am unsure of the exact syntax it must be in, can someone assist? I have included the section of coded below. I have replaced the double quote with an exclamation point for clarity.

If Mid(InputLine, I, 1) = "!" Then

inside_word = 0
End If

If Mid(InputLine, I, 1) = " " And inside_word = 0 Then
If Mid(InputLine, I - 1, 1) = "!" Then
end_ptr = I - 1
end_ptr = I
End If

Extended Ascii Characters - Vb6 Under Windows Xp Sp2
I am not sure this is a Unicode problem or else. Here was part of a program that simply composed a string.

dim strTemp as string
strTemp = Chr$(&HC7&) & "0001" & Chr$(&H04&)

It ran fine under Windows 2K pro. I tried to run the same program under Window XP SP2. It seemed to be having problems for extended ascii part (>128). Characters <=128 didn't have problem at all.

Under WinXP, I tried this in immidiate window:

print hex(asc(mid(strTemp,1,1)))

while the same command give you right answer under Windows 2K, i.e. C7.

Can any one tell me on what might be the problem?


How To Display Non-printable ASCII Characters
I am trying to display ASCII characters in a label, and those ASCII characters may not neccesarily fall into the range of printable characters. In other words, my form has a combo-box that lets the user pick any number between 1 and 255, and I will then display what the CHR(cboNumber.text) value LOOKS LIKE in a standard DOS screen. This works fine if the value is above 32 and below 127, but I ALSO want to display what the other characters look like as well as viewed in the DOS edit screen (THUS a chr(28) looks like an L on it's back etc.) I have found that I can change the characterset "charset" to 255, but that only works IF THE FONT SUPPORTS that character set, and after a dozen fonts, I may be on a wild goose chase. Any ideas!

Putting ASCII Characters Into A Text Box.
I'm working on a program that when I press a button, ASCII character 11 and the number 1 should enter the text box. But I don't know how to add the ASCII character.

Copyright 2005-08, All rights reserved