• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

convert tab keystroke to ascii value

Hello experts, I have so barcoding going on in one of my web pages.  And we want the tab keystroke to be a part of the bar code.  How can I do a conversion to make this work.  I need the ascii equivalent of a tab keystroke in vb.net.
0
tentavarious
Asked:
tentavarious
  • 12
  • 7
1 Solution
 
raterusCommented:
You can use the asc() function

Assuming you have a string with the tab...
Dim asciiValue as integer = asc(mytabstr)
0
 
tentavariousAuthor Commented:
Here is what I tried 009 is ascii for tab so how would i use your asc function?
The labelhold has a barcode font

  Sub getbarcodes(ByVal stringval As String, ByVal labelhold As Label, ByVal label2 As Label)
        If stringval <> "" Then
            labelhold.Text = "*" & stringval & "*" & Chr(9)
            label2.Text = stringval
        End If
    End Sub
0
 
raterusCommented:
now I'm confused, are you interested in printing the tab from "009" or taking the "009" and creating a tab?  I gave you the former.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
tentavariousAuthor Commented:
I think i made this more complicated then need be.  I want the ascii value of a tab keystroke concatenated with a label.
 009 is ascii for tab, so if I just concatenate 009 on the end of the label I think it would work, correct?  The label has a bar code font, so our bar code scanner needs to read the ascii for tab so that it can jump to the next line.
 
 Sub getbarcodes(ByVal stringval As String, ByVal labelhold As Label, ByVal label2 As Label)
        If stringval <> "" Then
            labelhold.Text = "*" & stringval & "009" & "*"    'I am not sure if concatenating 009 will work
            label2.Text = stringval
'labelhold is the bar code label
        End If
    End Sub
0
 
raterusCommented:
Ohh...try this

lablehold.Text = "*" & stringval & vbTab & "*"
0
 
raterusCommented:
and no, concatenating 009 wouldn't have worked :-)
0
 
tentavariousAuthor Commented:
ok, I will run the scanner across the bar code and see if works, I will get back to you soon.
0
 
tentavariousAuthor Commented:
Ok, it didnt work. This inserts 5 spaces into the barcode which is not what we want. lablehold.Text = "*" & stringval & vbTab & "*"  We need the scanner to read the ascii value.  I tried this:  labelhold.Text = "*" & stringval & Asc(vbTab) & "*".  This didnt work either.
0
 
tentavariousAuthor Commented:
The scanner just read in 9.
0
 
raterusCommented:
vbTab will most definitely insert a tab, not 5 spaces.  I would look at what could possibly be causing it to be reformatted to 5 spaces after this code is working.
0
 
tentavariousAuthor Commented:
I wonder if anything like this would work
 Dim myindex As Integer
        myindex = Asc(vbTab)
        Dim myd As Char
        myd = Chr(myindex)
        If stringval <> "" Then
            labelhold.Text = "*" & stringval & myd & "*"
            label2.Text = stringval
        End If
0
 
tentavariousAuthor Commented:
I tried it again all of the labels used in the sub procedure have a bar code font of 3 of 9 Barcode, 40pt.

Here is my entire page code.  5 parameters are passed to the page when it is loaded.  When I use the vbtab there are 5 spaces between stringval and *.

  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not Page.IsPostBack Then
            lblerror.Visible = False
             Try
                lbldate.Text = Today 'show current date
                getbarcodes(Request.QueryString("part"), lblpartbar, lblpart) 'i need to get parameter name
                getbarcodes(Request.QueryString("fm_sub"), lblsubbar, lblsub)
                getbarcodes(Request.QueryString("qty"), lblqtybar, lblqty)
                getbarcodes(Request.QueryString("to_sub"), lbltosubbar, lbltosub)
                If Not Request.QueryString("comment1") Is Nothing Then
                    lblcomment.Text = Request.QueryString("comment1")
                End If
            Catch ex As Exception
                lblerror.Text = ex.Message
                lblerror.Visible = True
            End Try
        End If
    End Sub
   
    Sub getbarcodes(ByVal stringval As String, ByVal labelhold As Label, ByVal label2 As Label)
              If stringval <> "" Then
            labelhold.Text = "*" & stringval & vbTab & "*"
            label2.Text = stringval
        End If
    End Sub
End Class
0
 
raterusCommented:
you're running this tabbed string through a label control, and who knows what that's going to do to it.

If you need a literal tab printed in the HTML, use an <asp:literal ... > control (Just tested it, a tab was printed in the HTML, a label control messed it up)
0
 
tentavariousAuthor Commented:
When I do something like this and step through the code the value of myindex looks like this: "      "
 Dim myindex As String
        myindex = vbTab
0
 
tentavariousAuthor Commented:
Ok, how do i set font properties for the literal control
0
 
raterusCommented:
I think we're getting a little off subject from the original question here,

you don't set fonts or any other formatting on the literal control as the literal control is one of the most basic controls there is.  It simply outputs the "Text" property to the HTML, no formatting is ever done.

if you want to set the font, you need to write the correct HTML to do what you want in the text property
0
 
tentavariousAuthor Commented:
Ok, well i am trying something like this in my code behind I gotta work with the syntax but I should get it working.
 literalval.Text = "style='FONT-WEIGHT: normal; FONT-SIZE: 40pt; FONT-FAMILY: '3 of 9 Barcode''& " * " & stringval & vbTab & " * ""
         
0
 
tentavariousAuthor Commented:
Well, i am trying to get this literal control to work and I got the font working, but I cant see to get the vbtab working correctly.

    labelhold.Text = "<font style='FONT-WEIGHT: normal; FONT-SIZE: 40pt; FONT-FAMILY: 3 of 9 Barcode'> vbTab </font>"
            label2.Text = stringval
0
 
tentavariousAuthor Commented:
Ok, this is what I got I am using a literal control and there is still a space in the bar code

 Sub getbarcodes(ByVal stringval As String, ByVal labelhold As Literal, ByVal label2 As Label)
        If stringval <> "" Then
            labelhold.Text = "<font style='FONT-WEIGHT: normal; FONT-SIZE: 40pt; FONT-FAMILY: 3 of 9 Barcode'>*" & stringval & "" & vbTab & "*</font>"
            label2.Text = stringval
        End If
    End Sub
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 12
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now