Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > อบถามการใช้ Label ของVB2010 ให้แสดงผลเป็นตัวเลข2หลัก เช่น 00 ต้องทำยังไงครับ



 

อบถามการใช้ Label ของVB2010 ให้แสดงผลเป็นตัวเลข2หลัก เช่น 00 ต้องทำยังไงครับ

 



Topic : 126259



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์




ต้องทำยังไงให้ ค่า แสดงผล 2 หลัก เป็น 00 ครับ

เช่น 01+01 = 02



Tag : .NET, VB.NET, VS 2010 (.NET 4.x)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2017-02-04 21:32:52 By : mogkung View : 1220 Reply : 8
 

 

No. 1



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

ToString("00")






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-05 00:02:08 By : lamaka.tor
 


 

No. 2



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์


Code (VB.NET)
 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        time = Date.Now.ToString.Split(" ")(1)
        Label1.Text$ = time
        If i = 1 And time.Substring(0, time.Length - 3) = Label2.Text$ & ":" & Label4.Text$ And
            time.Substring(time.Length - 2, 2) = "00" Then
            Timer1.Stop()
            My.Computer.Audio.Play(My.Resources.beep, AudioPlayMode.BackgroundLoop)
            Me.WindowState = FormWindowState.Normal
            Dim p As New Point
            p.X = (Me.Width / 2) - (Label1.Width / 2)
            p.Y = Label1.Top
            If Not Label1.Text$ = vbNullString Then
                Label1.Location = p
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label2.Text = TextBox1.Text
        Label4.Text = TextBox2.Text + 1
        If Button1.Text$ = "ENABLE" Then
            Button1.Text$ = "DISABLE"
            i = 1
        Else
            My.Computer.Audio.Stop()
            TextBox1.Clear()
            TextBox2.Clear()
            Timer1.Start()
            i = 0
            Button1.Text$ = "ENABLE"

        End If
        If Label4.Text >= 60 Then
            Label2.Text = Label2.Text + 1
            Label4.Text = Label4.Text - 60
        End If

    End Sub


ต้องเพิ่มในส่วนใหนเหรอครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-05 00:27:58 By : mogkung
 

 

No. 3



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

Code (VB.NET)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim a, b As Integer
        a = 2
        b = 5
        Label1.Text = (a + b).ToString("00")
    End Sub

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-05 00:30:00 By : lamaka.tor
 


 

No. 4



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์


เกือบเข้าใจแหะ มันเป็น label4 มันเป็น 3 จริงๆต้องเป็น 03 ตั้งค่าให้ มีเสียงดังเหมือน label4ตรงกับ นาฬิกาอะครับ
ไม่รู้จะเอา Tostring ไปวา่งตรงใหนดี
Tostring


ขอโทษจริงๆครับ พึ่งหัดทำครั้งแรก ฝึกตามYoutube มาล้วน :(


ประวัติการแก้ไข
2017-02-05 00:50:43
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-05 00:47:35 By : mogkung
 


 

No. 5



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

convert จาก Date.Now.ToString ก็ได้เช่นกัน

Code (VB.NET)
 Date.Now.ToString("hh:mm:ss")


แต่ถ้าไม่สะดวก ก็คงต้อง convert String เป็น ตัวเลข แล้ว เอาตัวเลขมา convert ToString

Code (VB.NET)
        Dim str = "6"
        Label1.Text = Integer.Parse(str).ToString("00")

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-05 01:05:56 By : lamaka.tor
 


 

No. 6



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์


Code (VB.NET)
  Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        time = Date.Now.ToString.Split(" ")(1)
        Label1.Text$ = time
        If i = 1 And time.Substring(0, time.Length - 3) = Label2.Text$ & ":" & Label4.Text$ And
            time.Substring(time.Length - 2, 2) = "00" Then
            Timer1.Stop()
            My.Computer.Audio.Play(My.Resources.beep, AudioPlayMode.BackgroundLoop)
            Me.WindowState = FormWindowState.Normal
            Dim p As New Point
            p.X = (Me.Width / 2) - (Label1.Width / 2)
            p.Y = Label1.Top
            If Not Label1.Text$ = vbNullString Then
                Label1.Location = p
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label2.Text = TextBox1.Text
        Label4.Text = TextBox2.Text + 1


        If Button1.Text$ = "ENABLE" Then
            Button1.Text$ = "DISABLE"
            i = 1
        Else
            My.Computer.Audio.Stop()
            TextBox1.Clear()
            TextBox2.Clear()
            Timer1.Start()
            i = 0
            Button1.Text$ = "ENABLE"

        End If
        If Label4.Text >= 60 Then
            Label2.Text = Label2.Text + 1
            Label4.Text = Label4.Text - 60
        End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer2.Start()
        Dim Str = "6"
        Label4.Text = Integer.Parse(Str).ToString("00")
    End Sub


ผมลองใส่ไปแล้วแต่เป็นเหมือนเดิมเลยอะครับ ให้ Label4.Text +1 ไว้ด้วย มันไม่ออกเป็น03 อะครับ

ฺboss
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-05 01:34:29 By : mogkung
 


 

No. 7



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์


Code (VB.NET)
        Dim str = Label4.Text
        Label4.Text = Integer.Parse(str).ToString("00")

    End Sub


ได้แล้วครับ ขอบคุณมากๆ
ได้แล้ว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-05 01:51:06 By : mogkung
 


 

No. 8



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-05 07:13:17 By : lamaka.tor
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อบถามการใช้ Label ของVB2010 ให้แสดงผลเป็นตัวเลข2หลัก เช่น 00 ต้องทำยังไงครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่