将数值从文本框更新为db [英] update numeric value from textbox to db

查看:66
本文介绍了将数值从文本框更新为db的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经坚持了一段时间..

i've been stuck with it for a while..

我的db(sqlite)值设置为double。当我尝试从文本框更新(每个keydown更新数据库)我每次删除一个值时出现一堆错误,文本框是空白的,当我偶然键入一个字符或尝试使用减号" - " ;。

my db (sqlite) value is set to double. when i try to update from a textbox (each keydown updates the db) i get bunch of errors every time i delete a value and the textbox is blank, when i type a charecter by accident or try to use the minus sign "-".

实际上,如果我在输入一个数字后使用它而不是之前使用减号它会起作用.. 

actually, with the minus sign it works if i use it after entering a number and not before.. 

我理解db不能接受非数字字符的逻辑,但我不能强迫它只提供数字,减号或保持空白..

i understand the logic that the db cant accept non-numeric characters but i can't force it to reffer only to numbers ,minus sign or keep it blank..

帮助任何人吗?

推荐答案

你好noampro8

Hi noampro8

这样做

Private Sub TextBox_KeyDown(Sender As Object, e As KeyEventArgs) Handles TextBox.KeyDown Try If e.KeyCode = Keys.Enter Then If String.IsNullOrEmpty(Sender.Text) = False AndAlso Microsoft.VisualBasic.IsNumeric(Sender.Text) Then 'Do Update e.SuppressKeyPress = True Else System.Windows.Forms.SendKeys.Send("{TAB}") e.SuppressKeyPress = True End If End If Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error) End Try End Sub


这篇关于将数值从文本框更新为db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆