Visual Basic中的StreamWriter [英] StreamWriter in Visual Basic

查看:120
本文介绍了Visual Basic中的StreamWriter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在Visual Basic中的Streamwriter中我的文本分类有问题.


该怎么做?

谢谢!

[edit]添加了代码块-OriginalGriff [/edit]

Hello, I have a problem in the classifications of my texts in streamwriter in visual basic.


How to do this?

Thank you!

[edit]Code block added - OriginalGriff[/edit]

推荐答案

简单:您只需要更改一行即可:
Easy: you just need to change one line:
textfilestream.WriteLine(Product & " " & Size & " " & Cost)


变为:


becomes:

textfilestream.WriteLine("Product: " & Product & " Size: " & Size & " Cost: " & Cost)



还是有高级版本:



Or there is the advanced version:

extfilestream.WriteLine("Product: {0} Size: {1} Cost : {2}", Product, Size, Cost)

,这看起来很复杂,但它的意思是如果我有一对大括号,请将其替换为末尾列表中的一个值".因此,将"{0}"替换为第一个参数,将"{1}"替换为第二个参数,依此类推.稍后,您将学习如何使用它来更改数字等的显示方式.习惯了就很简单!

[edit]添加格式字符串版本-OriginalGriff [/edit]



好吧,我有一个包含3个项目的组合框:产品尺寸和成本.

我也有一个maskedtextbox.

如果我在组合框上选择产品"和尺寸",我想禁止maskedtextbox填充,该怎么办?"


这比较复杂,我不确定您是否有足够的背景知识.
因此,如果这对您来说是傻瓜,我就不解释了!它可以等到您达到目标为止.

1)处理ComboBox的SelectionChanged事件.
2)在处理程序中,如果选择为"Product and Size",则将MaskedTextBox.Enabled属性设置为false.
3)否则,将其设置为true.

您可能需要在Form.Load事件中正确设置属性,以确保在用户单击任何内容之前该属性正常.

This make look complicated, but all it is saying is "Where I have a pair of curly brackets, replace this with a value from the list at the end". So "{0}" is replaced with the first parameter, "{1}" by the second and so on. Later, you will learn how to use this to change how numbers and so on are displayed. It''s simple when you get used to it!

[edit]Format string version add - OriginalGriff[/edit]



"Well I have a combobox with 3 items namely: Product Size and Cost.

I have also a maskedtextbox.

If I select "Product" and "Size" on the combobox, I want to disable the maskedtextbox from filling, how must I do it?"


That''s more complicated, and I''m not sure you have enough background for it yet.
So if this is gobble-de-gook to you, I''m not explaining it! It can wait until you reach it in your course.

1) Handle the SelectionChanged event for the ComboBox.
2) In the handler, if the selection is "Product and Size" then set the MaskedTextBox.Enabled property to false.
3) Otherwise, set it to true.

You will probably need to set the property correctly in your Form.Load event as weell to ensure it is OK before teh user clicks anything.


这篇关于Visual Basic中的StreamWriter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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