I am trying to set a const string made up of Chr(), but if the value
passed into Chr() is too large, the compiler complains that it is not
constant!! Example:
Public Const m_Data As String = Chr(&HD) & Chr(&HE) 'ok
Public Const m_Data As String = Chr(&HD0) & Chr(&HE0) 'not ok
But, Char stores 0..255, so it should be ok in both cases. What's
going on?
Zytan 7 2580
"Zytan" <zy**********@y ahoo.comschrieb :
>I am trying to set a const string made up of Chr(), but if the value
passed into Chr() is too large, the compiler complains that it is not
constant!! Example:
Public Const m_Data As String = Chr(&HD) & Chr(&HE) 'ok
Public Const m_Data As String = Chr(&HD0) & Chr(&HE0) 'not ok
But, Char stores 0..255, so it should be ok in both cases. What's
going on?
Note that 'Chr' uses Windows ANSI. Maybe it's better to use 'ChrW', which
is Unicode-enabled, instead.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Hello Zytan,
Public Const m_Data As String = Chr(&HD) & Chr(&HE) 'ok
Public Const m_Data As String = Chr(&HD0) & Chr(&HE0) 'not ok
But, Char stores 0..255, so it should be ok in both cases. What's
going on?
It might be a Unicode issue. Try ChrW instead.
Best regards,
Martin
Note that 'Chr' uses Windows ANSI. Maybe it's better to use 'ChrW', which
is Unicode-enabled, instead.
You are completely right. I knew the above, but i didn't think it
mattered. I was thinking ChrW() would return a two byte Char. Which
it does, and so does Chr(), since it's all unicode in VB .NET. Duh.
I still don't understand why it was complaining. I should note that
Chr() does accept 0..255, and I was within that range. So, something
is still wrong here.
But your suggestion works, so thanks!
Zytan
"Zytan" <zy**********@y ahoo.comschrieb :
>Note that 'Chr' uses Windows ANSI. Maybe it's better to use 'ChrW', which is Unicode-enabled, instead.
You are completely right. I knew the above, but i didn't think it
mattered. I was thinking ChrW() would return a two byte Char. Which
it does, and so does Chr(), since it's all unicode in VB .NET. Duh.
I still don't understand why it was complaining. I should note that
Chr() does accept 0..255, and I was within that range. So, something
is still wrong here.
'Chr' does not accept values greater than 127 when used in constants. The
reason is that 'Chr' would return different characters depending on the
system's Windows ANSI codepage for larger values. 'ChrW' always returns the
same character for a certain character code.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
'Chr' does not accept values greater than 127 when used in constants.
Sounds peculiar...
The
reason is that 'Chr' would return different characters depending on the
system's Windows ANSI codepage for larger values.
....until you said that.
'ChrW' always returns the
same character for a certain character code.
It all makes sense. And now that's something I'll remember. Again,
thanks for a very informative post, Herfried.
Zytan
It might be a Unicode issue. Try ChrW instead.
>
Best regards,
Martin
Yup, thanks. Please read Herfried's very informative post for the
precise cause.
Zytan
Note that 'Chr' uses Windows ANSI. Maybe it's better to use 'ChrW', which
is Unicode-enabled, instead.
Wait, luckily i had a debug.assert() to ensure things were ok, and i
found the following are not equivalent:
Dim a As String = Chr(&HD0) & Chr(&HE0)
Dim b As String = ChrW(&HD0) & ChrW(&HE0)
So, using ChrW(), while it allows b to be Const, where a cannot be
Const, it does not make b = a.
Zytan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven T. Hatton |
last post by:
In the following code, the only way I can figure out to pass an array of
const is by setting the template argument to const in the instanciation
expression. It would be (or seem to me) better if I could set that
qualifier in the function call. Can that be done?
#include <iostream>
using std::ostream;
using std::cout;
|
by: p|OtrEk |
last post by:
What is practic difference between this two declarations?
If i want call my func with func("blah") i could write:
1) func(std::string const& arg1)
2) func(const std::string& arg1)
Whats better to use if i dont want to change content of arg1 it in func
body?
--
<< pozdrawiam -lysek- @ irc.freenode.net#linux.com.pl
<< prompt$ :(){ :|:& };:
<< echo mail | sed 's/__NOSPAM//g'
|
by: C L Humphreys |
last post by:
Hi,
I'm trying to concatenate address fields and insert a LF&CR after each line.
The SQL I use is based on
select
address1 & chr(10) & chr(13)&
address2 & chr(10) & chr(13)&
address3 & chr(10) & chr(13)&
address4 & chr(10) & chr(13)&
|
by: jdph40 |
last post by:
I am trying to enter text to look like paragraphs in a text box on a
report, making it look like a memo. I enter (Chr$(13) & Chr$(10) &
Chr$(10)) to insert a carriage return and 2 line breaks, but a small
black square prints on the report. If I enter Chr$(10) once, the
square doesn't print. Can you only have one line break?
TIA,
JD
|
by: lauren quantrell |
last post by:
Has anyone cunstructed a function to remove multiple carriage returns
and replace it with a single return?
Replace(mytext, Chr(13) & Chr(10) & Chr(13) & Chr(10), Chr(13) &
Chr(10)) ...
only works to remove double carriage returns.
Thanks.
lq
| |
by: tom olson |
last post by:
After more searching I found that defining const operators
can cause problems with many compilers due to the way it
interprets the C++ standard. I removed the const
operators from my class and it seems to be working fine
now.
>-----Original Message-----
>I have C++ code that has been running just fine in VS6
for
>a couple of years. I brought it into VS.NET with managed
|
by: Darren Anderson |
last post by:
I have a function that I've tried using in an if then statement and I've
found that no matter how much reworking I do with the code, the expected
result is incorrect.
the code:
If Not (strIn.Substring(410, 10).Trim = "") Then
'Something processed
Else
'Something processed
|
by: Rich Shepard |
last post by:
I need to learn how to process a byte stream from a form reader where each
pair of bytes has meaning according to lookup dictionaries, then use the
values to build an array of rows inserted into a sqlite3 database table.
Here's the context: The OMR card reader sends a stream of 69 bytes over
the serial line; the last byte is a carriage return ('\r') indicating the
end of record. Three pairs (in specific positions at the beginning of the...
|
by: Joe Duchtel |
last post by:
Hello -
I was wondering why I can do a ...
Public Const A As Char = Chr(36)
.... but not a ...
Public Const B As Char = Chr(165)?
It seems like 0-127 are okay with the Chr(). Is this because values >
127 depend on the currently active code page and hence are dynamic?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |