B4R Question How do I cut a String or A value

Discussion in 'B4R Questions' started by pokhraj_d, Oct 28, 2018.

  1. pokhraj_d

    pokhraj_d Member

    Hello All,
    I required to get the last two digit of any value.
    Like :
    Degree=3051

    I want 51 only.
    How Do I cut and get the value of 51? I am able to get each digit of 3051 , but not the last two digit.

    Below is the code:
    Code:
    Public Serial1 As Serial
        
    Private b() As Byte="3051"
        
    Private bc As ByteConverter
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
    Dim i As Int=0
    For i = 0 To b.Length-1
        
    Dim c() As Byte=bc.SubString2(b,i,i+1)
        
    Log(c)
    Next
    End Sub
    Thanks-
    Pokhraj
     
  2. pokhraj_d

    pokhraj_d Member

    Done.... Result is coming as expected.

    Below is the code:

    Code:
    Public Serial1 As Serial
        
    Private b() As Byte= "088226677" '"08822"    '"3051"
        Private bc As ByteConverter
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
           
    Dim d() As Byte=bc.SubString(b,(b.Length-2))
        
    Log(b.Length)
        
    Log(d)
    End Sub
    Thanks-
    Pokhraj
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice