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
  1. Home
  2. General Programming
  3. Visual Basic
  4. why .....incorrect data printed from vb.net

why .....incorrect data printed from vb.net

Scheduled Pinned Locked Moved Visual Basic
databasecsharpsql-serversysadmin
3 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    Mr kilany
    wrote on last edited by
    #1

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Try Dim cone As New Conection Dim ii As Integer = ds.Tables(0).Rows(ComboBox1.SelectedIndex).Item(0) Dim sh As String = cone.get_Special_data("select Switch_Access_Code from Swiches where Swich_ID=" & ii & "") b2 = "" b2 = sh Me.WindowState = FormWindowState.Minimized System.Windows.Forms.SendKeys.SendWait(b2)//b2="2494:" come from //database on sql server Me.WindowState = FormWindowState.Normal b2 = "" Catch ex As Exception MsgBox("الرجاء اختيار القسم") End Try End Sub some times when i click on this button will type on active window 4294: but aslo some time type 44294: and some time 4294:: and some time 4294: and some time 4449942: althought the data which comes from data base is just 4294: why the variable b2 some time print wrong data not as want ??????? kilany

    D 1 Reply Last reply
    0
    • M Mr kilany

      Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Try Dim cone As New Conection Dim ii As Integer = ds.Tables(0).Rows(ComboBox1.SelectedIndex).Item(0) Dim sh As String = cone.get_Special_data("select Switch_Access_Code from Swiches where Swich_ID=" & ii & "") b2 = "" b2 = sh Me.WindowState = FormWindowState.Minimized System.Windows.Forms.SendKeys.SendWait(b2)//b2="2494:" come from //database on sql server Me.WindowState = FormWindowState.Normal b2 = "" Catch ex As Exception MsgBox("الرجاء اختيار القسم") End Try End Sub some times when i click on this button will type on active window 4294: but aslo some time type 44294: and some time 4294:: and some time 4294: and some time 4449942: althought the data which comes from data base is just 4294: why the variable b2 some time print wrong data not as want ??????? kilany

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It's not the B2 variable that has the problem. It's SendKeys. Using SendKeys to send data or control another application is NOT reliable, as you've already found out. You're quite literally stuffing the keyboard buffer with keys that are NOT guaranteed to make it to their intended target control. On top of that, if the target control already has data in it, you could be inserting this data into the middle, or whatever, of the existing data. Dave Kreskowiak Microsoft MVP - Visual Basic

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        It's not the B2 variable that has the problem. It's SendKeys. Using SendKeys to send data or control another application is NOT reliable, as you've already found out. You're quite literally stuffing the keyboard buffer with keys that are NOT guaranteed to make it to their intended target control. On top of that, if the target control already has data in it, you could be inserting this data into the middle, or whatever, of the existing data. Dave Kreskowiak Microsoft MVP - Visual Basic

        M Offline
        M Offline
        Mr kilany
        wrote on last edited by
        #3

        ok .. can you give me the best way t o pass a data without any lossing of data... thanx alot friend kilany

        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