String.Format
zone formatting
String.Format("{0, 10}{1, 3}{0,5}", "hi", 6)
TextBox1.Text = String.Format("{0, -10}{1, 3:N3}{0,5}", "hi", 0.6)
all these format function take in parameters of various types, but they ALL generate Strings
josh.txt
this will sit in a specific folder
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = String.Format("{0, -10}{1, 3:N3}{0,5}", "hi", 0.6)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim sr As IO.StreamReader
sr = IO.File.OpenText("C:\vbfiles\josh.txt")
Dim sentence As String
sentence = sr.ReadLine()
Dim myNumber As Double
myNumber = CDbl(sr.ReadLine())
TextBox1.Text = myNumber & ";" & sentence
sr.Close()
End Sub
End Class
how it will work with Loops
Do While sr.Peek() <> -1
Loop
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim t As String
t = InputBox("Please enter a name", "Give a name", "Josh")
TextBox1.Text = t
End Sub
No comments:
Post a Comment