|
Hi Cory,
the following line of code converts one string to one byte, expecting a hexadecimal
representation of the byte's value:
byte.Parse("e9", NumberStyles.AllowHexSpecifier)
it would throw an exception on bad input; the alternative TryParse() would not.
if your string contains more data, you would have to split it (using either String.Split
or String.Substring).
if you have an array of strings each representing one byte, and want an array of bytes,
you would have to create a byte array (with same dimension as the string array), then
loop over each array element.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Please look at my code. When I send a string str ="4003" in function I am not getting Hex byte.
The Do While will grab each char in the string array. When "4" goes through it is converted to a Hexidecimal string. When I try your suggested code bytes(i) = Byte.Parse(sValue, Globalization.NumberStyles.AllowHexSpecifier) sValue is equal to "34" it converts from the Hexidecimal string to a Decimal byte.
Do While str.Length > 0
'first I take each character using substring
sValue = str.Substring(0, 1).ToString()
'then convert character into ascii.
sValue = Strings.Asc(sValue)
'then convert ascii value into Hex Format
sValue = Conversion.Hex(sValue)
'after converting remove the character.
sHex(count) = sValue
bytes(i) = Byte.Parse(sValue, Globalization.NumberStyles.AllowHexSpecifier)
count = count + 1
str = str.Substring(1, str.Length - 1)
i = i + 1
What am I doing wrong.
Thanks for your help.
|
|
|
|
|
Hi,
you are still confusing everything: hexadecimal, ASCII, char and byte.
Tell me what you want in examples, not words (you mix them up),
and not code (since I assume you ask because it does not do what you want).
From the examples I'll try to put it in correct words and maybe code too.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
EX1:
4003
turn into
byte() of Hexidecimals {34, 30, 30, 33}
EX2:
Changed
turn into
byte() of Hexidecimals{63,68,61,6E,67,65,64}
|
|
|
|
|
OK, I think that would be
"how to convert a string to a byte array containing the ASCII values of the
string's characters"
unless the string also might contain non-ASCII characters, in which case additional
specifications would be required.
So there is no string array, and actually there is nothing hexadecimal at all.
A byte is a byte, hexadecimal is just a way of looking at the content of the byte.
That is: the character '1' in ASCII is coded as a byte with decimal value 49,
hexadecimal value 31, binary value 00110001, octal value 061, that's all the same byte.
The job is handled by the following line of C# code:
byte[] AsciiByteArray=Encoding.ASCII.GetBytes(myInputString);
Since all Framework classes are available to VB.NET too, I trust you will know
how to do the same in one line of VB.NET
BTW: if the input is not ASCII but some other encoding, chances are that encoding
is also available in .NET and just requires a minor modification of the code.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I’m using vb.net 2005 on vista32.
WMI Class "CIMV2\Win32_VideoSettings" does not work under Vista.
Do you know an other possibility?
Sven.
|
|
|
|
|
Looking for an OS-specific list is pointless. What if you have two screens on two different graphics adapters? The supported resolutions is a property of the graphics adapter, not the OS, so I'd suggest you look in the WMI classes for the graphics adapters.
|
|
|
|
|
Great Idea,
What class exactly do you mean ?
I couldn’t found any....
|
|
|
|
|
Hi,
are you saying you have WMI code that runs on XP but not on Vista ?
If so, you may want to try good old Win32 functions such as EnumDisplaySettings in user32.dll
although I don't know how that behaves on Vista.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
in reports , can i show the graph .i mean, suppose i have three fields , which have their respective percentage.
like a 10%
b 40%
c 50%
so graph should show
a 10% in red
b 40% in green
c 50% in yellow
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Google for "ZedGraph" and you'll find a free graphing library that can do this.
|
|
|
|
|
yes! u can certainly do that in vb.net itself i hav done that
U just click the graph button in u r crystal report u will be popped up
with a window there u can select u r fields to "Show Value(s)" which is to be shown in Graph, But don't Forget to select the Field to "On change of"
b,coz based on this field u r graph are being displayed.
how it helped , reply !
Prabumj
-- modified at 14:21 Thursday 9th August, 2007
prabumj@gmail.com
-- modified at 0:26 Friday 10th August, 2007
|
|
|
|
|
can we able to put a camera function in vb.net sistem.I want to use camera so that the user can take picture from the system and saved it.Is it posible to do so?
do anyone have any idea how?
@h3aR
|
|
|
|
|
|
I have an article on remote controlling Canon cameras. Just taking a basic picture is doable with most digital cameras with WIA
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i have made sql statement
this stamene between 2 dates I mean between datepicker 1 and datepicker2
and i use the results to show it in report
what i need is how to put this 2 dates in the report to spacify this report between these two dates
so that the report will be this is the results from date1 to date2
and the results is 2467,2378,238732 and so on
|
|
|
|
|
hi
you can create 2 formula field in report and set their values from code like this
report.fielddefinition.formulafields(fDateindex).text = "Date (yy, MM, dd)"
report.fielddefinition.formulafields(tDateindex).text = "Date (yy, MM, dd)"
the other is you can create 2 parameters in report and set their values form code like this
report.fielddefinition.parameterfields(fDateindex) = "Date (yy, MM, dd)"
report.fielddefinition.parameterfields(tDateindex) = "Date (yy, MM, dd)"
best of luck
Salman Sheikh
|
|
|
|
|
Hello,
I think u using the datetimepicker from the form means. We will send the datetimepicker's value as argument to the Report.
Consider
Dim objcrpdetail As New CryReprot
objcrpdetail.SummaryInfo.ReportTitle = "'"& DateTimePicker1.value &"'
objcrpdetail.SummaryInfo.ReportComments = "'"& DateTimePicker2.value &"'
objcrpdetail.SetDataSource(Dset.Tables(0))
CrystalReportViewer1.ReportSource = objcrpdetail
Here objcrpdetail is Report name as object instant.Then We passing Crystal Report's ReportTitle as DateTimePicker1.value and ReportComments = DateTimePicker2.value as argument to the report called CryReprot. And iam using Dset for data sending to the report.
In the crystal report -> Special Fields -> ReportTitle, ReportComments are available. Click n drag n use it in ur report..
Pls send me ur opinions to me.......
Senthil S
Software Engineer
|
|
|
|
|
hi frnds,
i want to enter only numeric values in a textbox, how can i ?.. like 123.256 or -123.456 ...
cheers..
|
|
|
|
|
use the textchanged event of the textbox and check if it is numeric with isnumeric function (returns a boolean)
|
|
|
|
|
Hello,
I think this is the solution for ur qustion. Pls reply wat ever u got, Ok
If (Asc(e.KeyChar)) = 46 Or (Asc(e.KeyChar)) = 45 Or (Asc(e.KeyChar)) = 8 Then
e.Handled = False
ElseIf e.Handled = Char.IsNumber(e.KeyChar) = True Then
e.Handled = True
End If
Senthil S
Software Engineer
|
|
|
|
|
Senthil S wrote: (Asc(e.KeyChar))
What is this ?
Senthil S wrote: ElseIf e.Handled = Char.IsNumber(e.KeyChar) = True Then
What does this do ?
The solution is to check Char.IsNumber and Char.IsControl, if both fail, then e.Handled should be true.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
I got the out put without any exception. I checked n then only i displayed this msg...
(Asc(e.KeyChar))
is return to check the "." n "-" key. If the user may not need to find the entered value to be number.
ElseIf e.Handled = Char.IsNumber(e.KeyChar) = True Then
if both condition fails then it return nothing in that textbox.
Use that code n check in vb.net 2005. N blame me....
Senthil S
Software Engineer
|
|
|
|
|
in keypress event you can write as follows
If Not Char.IsNumber(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not e.KeyChar = "." Then
e.Handled = True
ElseIf e.KeyChar = "." Then
If Me.Text.IndexOf(e.KeyChar) > 0 Then
e.Handled = True
End If
End If
Salman Sheikh
|
|
|
|
|
check out my article from the link in my signature on a self validating textbox...the numeric field doesn't handle negative but it wouldn't be hard to change that.
|
|
|
|