如何在不使用VC ++转换的情况下读取TextBox值(How to read TextBox values without conversion in VC++)
我使用Visual Studio 2013构建了一个表单,并使用C ++。 我的目标是从文本框中读取值并将其写入二进制文件。
我面临的问题是,当我输入十六进制值时,它仍然会转换为十六进制,我想在没有转换的情况下编写它。
Char id1= Convert::ToByte(textBox1->Text); UInt16 id2= Convert::ToInt16(textBox2->Text); UInt32 id3= Convert::ToInt32(textBox3->Text); String^ fileName = "id.id"; FileStream^ fileStr = gcnew FileStream(fileName, FileMode::Append); BinaryWriter^ binwr = gcnew BinaryWriter(fileStr); binwr->Write(id1); binwr->Write(id2); binwr->Write(id3); fileStr->Close(); binwr->Close();所以如果我输入8041我想在二进制文件8041中不是1f08。
谢谢
I've built a form with Visual Studio 2013 and I'm using C++. My goal is to read the values from a textbox and write them to a binary file.
The problem I face is that when I input a hex value it is still converted to hex and I would like to write it without conversion.
Char id1= Convert::ToByte(textBox1->Text); UInt16 id2= Convert::ToInt16(textBox2->Text); UInt32 id3= Convert::ToInt32(textBox3->Text); String^ fileName = "id.id"; FileStream^ fileStr = gcnew FileStream(fileName, FileMode::Append); BinaryWriter^ binwr = gcnew BinaryWriter(fileStr); binwr->Write(id1); binwr->Write(id2); binwr->Write(id3); fileStr->Close(); binwr->Close();So if I input 8041 I would like to have in the binary file 8041 not 1f08.
Thanks
最满意答案
基于@Some程序员哥们的评论
UInt16 id2= Convert::ToInt16(textBox2->Text, 16);是正确的答案。
谢谢@有些程序员老兄!
Based on @Some programmer dude 's comment
UInt16 id2= Convert::ToInt16(textBox2->Text, 16);is the right answer.
Thank you @Some programmer dude !
更多推荐
发布评论