小编Nil*_*h B的帖子

使用字典的键更新值

Dictionary在VB.NET Windows应用程序中使用.

我在a中添加了几个值,Dictionary我想使用它们的键来编辑一些值.

示例:下面我们有一个DATA表,我想将密钥的值 - "DDD"更新为1

AAA - "0"   
BBB - "0" 
CCC - "0' 
DDD - "0"
Run Code Online (Sandbox Code Playgroud)

如何才能做到这一点?

For Each kvp As KeyValuePair(Of String, String) In Dictionary1
    If i = value And kvp.Value <> "1" Then
        NewFlat = kvp.Key.ToString
        ---------------------------------------------
        I want to update set the Value 1 of respective key.
        What should I write here ? 
        ---------------------------------------------
        IsAdded = True
        Exit For
    End If
    i = i + 1
Next kvp
Run Code Online (Sandbox Code Playgroud)

vb.net vb.net-2010

8
推荐指数
1
解决办法
3万
查看次数

如何避免在Windows应用程序的文本框中使用特殊字符

我正在开发Windows应用程序.我有一个表单,我正在尝试验证该表单上的文本框.

我想在文本框上进行一些验证,比如文本框应该只接受Alphabates,Didgits和逗号.(没有其他字符,如特殊符号.)同样,当光标在该文本框中时,它应该接受Enter键.

我正在尝试编写代码,但有些代码却无法正常工作.但它仍然采用像<> /;这样的特殊字符 我必须做出哪些改变?

这是代码......

击键事件

 Private Sub txtOLDBuildingName_KeyDown(sender As Object, e As KeyEventArgs) Handles txtOLDBuildingName.KeyDown

        ' Initialize the flag to false.
        nonNumberEntered = False

        ' Determine whether the keystroke is a number from the top of the keyboard. 
        If (e.KeyCode < Keys.D0 And e.KeyCode > Keys.D9) And (e.KeyCode > Keys.A And e.KeyCode < Keys.Z) Then
            nonNumberEntered = True
        End If
        'If shift key was pressed, it's not a number. 
        If Control.ModifierKeys = Keys.Shift Then
            nonNumberEntered = True
        End …
Run Code Online (Sandbox Code Playgroud)

vb.net visual-studio-2012

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

vb.net ×2

vb.net-2010 ×1

visual-studio-2012 ×1