将特殊字符从字符串保存到文本文件 [英] Save special character from string to text file

查看:129
本文介绍了将特殊字符从字符串保存到文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我这里有个情况.假设我在保存之前将某个变量变暗以保存字符串数据.

Hi all,

I have a situation here. Let''s say I dim some variable to hold a string data before save.

Dim answer As String



然后,我准备输入供用户填写.当他们单击保存"按钮时,我会将数据保存在答案"中,假设数据是IP"192.168.0.1",但是当保存数据时,它将是192.168.0.1,不带引号",对吗?

我想将数据保存到文本文件中.如何保存带引号的数据?可能吗.我已经尝试将双引号保存到字符串中,但是它将保存不带引号的数据.

帮帮我..



Then I ready an input for user to fill. When they click save button, I will hold the data into "answer", let''s say the data is an IP "192.168.0.1" but when the data is save, it will be 192.168.0.1 without quote "" right?

I want to save the data into text file. How could I save the data with the quotes? Is it possible. I''ve tried to save the double quotes into a string but it will save data without quotes.

Help me..

推荐答案

是的,有可能.您只需要使引号成为字符串本身的一部分即可.
Yes, it''s possible. You just have to make the quotes part of the string itself.
Dim myData As String = """192.168.0.1"""


现在,字符串的值将是带引号的"192.168.0.1".如果您将该字符串写入文件,它将包含引号.


Now the value of the string will be "192.168.0.1", WITH the quotes. If you write that string to a file, it''ll include the quotes.


这篇关于将特殊字符从字符串保存到文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆