vb.net - Can I Convert A Byte() to a string? -
i need solution current code, trying save text file text box, , add string it. following code is:
dim fs filestream = file.create(filename.text) ' add text file. dim info byte() = new utf8encoding(true).getbytes(codebox.text) dim code = "-- made lua creator sam v1.9 " + info fs.write(code, 0, code.length) fs.close() msgbox("file saved " + filename.text)
but visual studio says cannot use "+" operator strings & bytes:
error bc30452 operator '+' not defined types 'string' , 'byte()'.
anyone have solution? sorry if duplicate, couldn't find anywhere here asked myself. thanks.
"can convert byte() string?" short answer yes, doesn't you're wanting do.
you're trying concatenate string
byte
array, dim code
has no idea end result supposed be.
filestream.write()
requires byte
array can try couple of things
concatenate string textbox "header" information turn
byte
array.dim fs filestream = file.create(filename.text) ' add text file. dim code byte() = new utf8encoding(true).getbytes("-- made lua creator sam v1.9 " & codebox.text) fs.write(code, 0, code.length) fs.close()
write "header" information, write textbox information
dim fs filestream = file.create(filename.text) ' add text file. dim header byte() = new utf8encoding(true).getbytes("-- made lua creator sam v1.9 ") dim info byte() = new utf8encoding(true).getbytes(codebox.text) fs.write(header, 0, header.length) fs.write(info, 0, info.length) fs.close()
Comments
Post a Comment