Re: Converting a string
Len Porzio <[email protected]> Wed, 5 Sep 2007 10:15:40 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Jerry this sounds like you need to pursue type changes. On the VB side you would probably want to change the control code string to a BYTE array and on the Oracle side you might need to store it as some kind of raw or binary data type. This would ensure exact data transfer without manipulation. It's been a while since I've been in .Net land but there is probably a member function or conversion class somewhere that will then turn your byte array into a string. ~ Len On 9/5/07, Knowlton, Gerald F. <[email protected]> wrote: > Good morning everyone. > > Here is the problem that I have. I have this application which > will control weighing scales through a commport. There are many > different scales at this facility so I can't hard code into the > application the parameters of the currently attached scale. > > So in an Oracle (we use Oracle here) table, I have the commands for the > many different type of scales we have and there is no problem for us to > automatically identify the type of scale. Thus we have the ability to be > able to get from the database, the commands needed to tare, standardize, > weigh and etc functions. > > The problem is that for the most part, each command (but not all) > require some type of unprintable character(s) in the command string. > Most are the ESC key - ASCII 27. So in the database, we have the > following command "CHR(27) & ""P"" & CHR(13) & CHR(10)" for one type of > scale. This command will cause the scale to transmit the value on the > scale's display back to the application. > > So if I hard code the command into the application such as: > > Public Sub SendWeighCommand() > Dim ScaleCommand as string = chr(27) & "P" & chr(13) & chr(10) > Dim Weight as string > Weight = ReadScale(ScaleCommand) > End sub > > Public function ReadScale(Command) as Double > > 'Return scale value > > End function > > This will work us fine because the chr(27),10 and 13 get translated into > unprintable characters. They look something like a square. > > But since I am getting the command string from the Oracle database, > everything is enclosed in quotes and the chr 27, 10 , and 13 do not > convert to the unprintable characters. > > Public Sub SendWeighCommand() > Dim ScaleCommand as string = <Oracle command string> > Dim Weight as string > Weight = ReadScale(ScaleCommand) > End sub > > Public function ReadScale(Command) as Double > > 'Return scale value > > End function > > Hence the ScaleCommand would pass the following string " chr(27) & ""P"" > & chr(13) & chr(10)" instead of the "P" along with the unprintable > characters. > > I thought I could use the CallByName function so the string would > translate but it appears that this is not so. > > Are there any other solutions to this problem of getting the translation > of an Oracle string value? > > Please embarrass me with a really simple solution!!! > > Best regards, > > > Jerry Knowlton >