vb程序TEXT设计

vb程序TEXT设计,第1张

使用如下代码:

Private Sub Command1_Click()

'Text3.MultiLine = True

Dim a As String, err As String, str As String

Dim Times As Integer

If isInt(Text1.Text) = False Then

err = err + "打印初始值不是整数!"

ElseIf CInt(Text1.Text) > 999 Or CInt(Text1.Text) < 1 Then

err = err + "打印初始值不在1~999之间!"

Else

a = Text1.Text

End If

If isInt(Text2.Text) = False Then

err = err + "打印次数必须为整数!"

ElseIf CInt(Text2.Text) > 999 Or CInt(Text2.Text) < 1 Then

err = err + "打印次数必须在1~999之间!"

Else

Times = CInt(Text2.Text)

End If

If err = "" Then

For i = 0 To CInt(Text2.Text) Step 1

str = str + Text1.Text

Next

Text3.Text = str

Else

MsgBox err, vbOKOnly, "出错了"

End If

End Sub

'判断字符串是否为整数

Public Function isInt(s As String) As Boolean

If CStr(CInt(Val(s))) = s Then

isInt = True

Else

isInt = False

End If

End Function

窗体上有textbox控件三个,command控件一个,布置如图!

package day05

import java.io.BufferedWriter

import java.io.FileNotFoundException

import java.io.FileOutputStream

import java.io.IOException

import java.io.OutputStreamWriter

public class OutputStreamWriterTest {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

FileOutputStream fos=null

OutputStreamWriter osw=null

BufferedWriter bw=null

try {

fos=new FileOutputStream("d:\\tt.txt")

osw=new OutputStreamWriter(fos)

bw=new BufferedWriter(osw)

for(int i=0i<4i++)

{

for(int j=i/2j<ij++)

bw.write("¥")

bw.write("")

// bw.newLine()

bw.write("\r\n")

}

bw.flush()

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace()

}finally{

if(bw!=null)try{bw.close()}catch(IOException e){}

if(osw!=null)try{osw.close()}catch(IOException e){}

if(bw!=null)try{bw.close()}catch(IOException e){}

}

}

}

输出为大写:L


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11518685.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存