Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. How Create BarCode In ASP. net With C# . I Create Code In Asp.net With VB.net But I need ASP With C# [modified]

How Create BarCode In ASP. net With C# . I Create Code In Asp.net With VB.net But I need ASP With C# [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpgraphicsasp-netquestion
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IshtiaqueJ
    wrote on last edited by
    #1

    How Create Code Bar In ASP. net With C# . I Create Code In Asp.net With VB.net But I need ASP With C# I Send Code ASp.net With Vb.net BarCode This Code Working Properly But I need In ASP.net With C# ------------------------------------------------------------------------- --------------------------------------------------------------------------------------- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Input As String = Request.QueryString("input") Input = txtinput.Text Dim ValidInput As String = " !" & Chr(34) & "#$%&()**+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" & Chr(0) & Chr(1) & Chr(2) & Chr(3) & Chr(4) & Chr(5) & Chr(6) & Chr(7) & Chr(8) & Chr(9) & Chr(10) & Chr(255) Dim ValidCodes As String = "17401644163811761164110012241220112416081604157214361244123014841260125416501628161417641652190218681836183018921844184217521734159013041112109414161128112216721576157014641422113414961478114219101678158217681762177418801862181418961890181819141602193013281292120011581068106214241412123212181076107415541616197815561146134012121182150812681266195619401938175817821974140013101118151215061960195415021518188619661724168016926379" Dim Digit As Integer = 103 Dim i As Integer For i = 1 To Input.Length Digit += (i * InStr(1, ValidInput, Mid(Input, i, 1))) Next Digit = Digit Mod 103 Input = Chr(8) & Input & Mid(ValidInput, Digit, 1) & Chr(255) Dim bmp As Bitmap = New Bitmap((Input.Length * 11) + 13, 50) Dim g As Graphics = Graphics.FromImage(bmp) g.FillRectangle(New SolidBrush(Color.White), 0, 0, (Input.Length * 11) + 13, 50) Dim p As New Pen(Color.Black, 1) Dim BarValue, BarX As Integer Dim BarSlice As Short For i = 1 To Input.Length Try If InStr(1, ValidInput, Mid(Input, i, 1)) > 0 Then BarValue = Val(Mid(ValidCodes, ((InStr(1, ValidInput, Mid(Input, i, 1)) - 1) * 4) + 1, 4)) Digit = 11 If i = Input.Length Then Digit = 13 For BarSlice = Digit To 0 Step -1 If BarValue >= 2 ^ BarSlice Then g.DrawLine(p, BarX, 0, BarX, 50) BarValue = BarValue - (2 ^ BarSlice) End If BarX += 1

    B C 2 Replies Last reply
    0
    • I IshtiaqueJ

      How Create Code Bar In ASP. net With C# . I Create Code In Asp.net With VB.net But I need ASP With C# I Send Code ASp.net With Vb.net BarCode This Code Working Properly But I need In ASP.net With C# ------------------------------------------------------------------------- --------------------------------------------------------------------------------------- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Input As String = Request.QueryString("input") Input = txtinput.Text Dim ValidInput As String = " !" & Chr(34) & "#$%&()**+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" & Chr(0) & Chr(1) & Chr(2) & Chr(3) & Chr(4) & Chr(5) & Chr(6) & Chr(7) & Chr(8) & Chr(9) & Chr(10) & Chr(255) Dim ValidCodes As String = "17401644163811761164110012241220112416081604157214361244123014841260125416501628161417641652190218681836183018921844184217521734159013041112109414161128112216721576157014641422113414961478114219101678158217681762177418801862181418961890181819141602193013281292120011581068106214241412123212181076107415541616197815561146134012121182150812681266195619401938175817821974140013101118151215061960195415021518188619661724168016926379" Dim Digit As Integer = 103 Dim i As Integer For i = 1 To Input.Length Digit += (i * InStr(1, ValidInput, Mid(Input, i, 1))) Next Digit = Digit Mod 103 Input = Chr(8) & Input & Mid(ValidInput, Digit, 1) & Chr(255) Dim bmp As Bitmap = New Bitmap((Input.Length * 11) + 13, 50) Dim g As Graphics = Graphics.FromImage(bmp) g.FillRectangle(New SolidBrush(Color.White), 0, 0, (Input.Length * 11) + 13, 50) Dim p As New Pen(Color.Black, 1) Dim BarValue, BarX As Integer Dim BarSlice As Short For i = 1 To Input.Length Try If InStr(1, ValidInput, Mid(Input, i, 1)) > 0 Then BarValue = Val(Mid(ValidCodes, ((InStr(1, ValidInput, Mid(Input, i, 1)) - 1) * 4) + 1, 4)) Digit = 11 If i = Input.Length Then Digit = 13 For BarSlice = Digit To 0 Step -1 If BarValue >= 2 ^ BarSlice Then g.DrawLine(p, BarX, 0, BarX, 50) BarValue = BarValue - (2 ^ BarSlice) End If BarX += 1

      B Offline
      B Offline
      BalasubramanianK
      wrote on last edited by
      #2

      It will help u http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]

      Balasubramanian K.

      I 1 Reply Last reply
      0
      • B BalasubramanianK

        It will help u http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]

        Balasubramanian K.

        I Offline
        I Offline
        IshtiaqueJ
        wrote on last edited by
        #3

        I Do This already. But This Not Working Properly.

        1 Reply Last reply
        0
        • I IshtiaqueJ

          How Create Code Bar In ASP. net With C# . I Create Code In Asp.net With VB.net But I need ASP With C# I Send Code ASp.net With Vb.net BarCode This Code Working Properly But I need In ASP.net With C# ------------------------------------------------------------------------- --------------------------------------------------------------------------------------- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Input As String = Request.QueryString("input") Input = txtinput.Text Dim ValidInput As String = " !" & Chr(34) & "#$%&()**+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" & Chr(0) & Chr(1) & Chr(2) & Chr(3) & Chr(4) & Chr(5) & Chr(6) & Chr(7) & Chr(8) & Chr(9) & Chr(10) & Chr(255) Dim ValidCodes As String = "17401644163811761164110012241220112416081604157214361244123014841260125416501628161417641652190218681836183018921844184217521734159013041112109414161128112216721576157014641422113414961478114219101678158217681762177418801862181418961890181819141602193013281292120011581068106214241412123212181076107415541616197815561146134012121182150812681266195619401938175817821974140013101118151215061960195415021518188619661724168016926379" Dim Digit As Integer = 103 Dim i As Integer For i = 1 To Input.Length Digit += (i * InStr(1, ValidInput, Mid(Input, i, 1))) Next Digit = Digit Mod 103 Input = Chr(8) & Input & Mid(ValidInput, Digit, 1) & Chr(255) Dim bmp As Bitmap = New Bitmap((Input.Length * 11) + 13, 50) Dim g As Graphics = Graphics.FromImage(bmp) g.FillRectangle(New SolidBrush(Color.White), 0, 0, (Input.Length * 11) + 13, 50) Dim p As New Pen(Color.Black, 1) Dim BarValue, BarX As Integer Dim BarSlice As Short For i = 1 To Input.Length Try If InStr(1, ValidInput, Mid(Input, i, 1)) > 0 Then BarValue = Val(Mid(ValidCodes, ((InStr(1, ValidInput, Mid(Input, i, 1)) - 1) * 4) + 1, 4)) Digit = 11 If i = Input.Length Then Digit = 13 For BarSlice = Digit To 0 Step -1 If BarValue >= 2 ^ BarSlice Then g.DrawLine(p, BarX, 0, BarX, 50) BarValue = BarValue - (2 ^ BarSlice) End If BarX += 1

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          This is horrible, horrible VB.NET code. However, in an ASP.NET project, you can have some pages that use VB and some that use C# . Just make this a VB page. I'd also generate the images in an aspx, so that you don't ever have to save them to the HDD, just stream them to the page.

          Christian Graus Driven to the arms of OSX by Vista.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups