使用vb.net使用控件单选按钮保存文本框 [英] save textbox with control radiobutton using vb.net

查看:110
本文介绍了使用vb.net使用控件单选按钮保存文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..
在gridview中单击复选框后,
勾选从计算机当前时间检索的单选按钮后,我还将日期时间保存在文本框中,我有4个文本框和4个单选按钮,
所有日期时间都应保存到数据库中,
所以现在我无法保存或将从单选按钮检索到的日期时间插入数据库.

我编码的这一部分:

hi guys..need favor..
after clicking checkbox in gridview,
i also save the datetime in textbox once tick the radiobutton which retrieve from computer current time, i have 4 textbox and 4 radiobutton,
all the datetime should save to database,
so now i cannot save or insert the datetime that i retrieve from radiobutton into database.

this part of my coding:

If RadioButton4.Checked = True Then
                    If ExitTimeOut1 = TextBox4.Text Then
                       
                    Else
                        MyComm2.CommandText = "update ExitPassDetails set ExitTimeOut1 = ''" & ExitTimeOut1 & "'', Remarks = ''" & Reason & "'' where ExitID = ''" & id & "'' "

                        sqlconnect2.Open()

                        Dim result2 As Data.SqlClient.SqlDataReader = MyComm2.ExecuteReader(Data.CommandBehavior.CloseConnection)

                        result2.Read()
                        

                        sqlconnect2.Close()
                    End If


问候
Aleesya


Regards
Aleesya

推荐答案

您在写什么?!!

What are you writing?!!

If RadioButton4.Checked = True Then '...



正式地,不是bug,但是您真的了解您在做什么吗?!
您将布尔值与True进行比较,而True始终等于相同的布尔值.
这与写If 2=2大致相同.必须为:



Formally, not a bug, but do you really understand what are you doing?!
You compare Boolean with True which is always equal to the same Boolean.
This is approximately the same as writing If 2=2. Must be:

If RadioButton4.Checked = True Then '...



您如何比较



How come you compare

If ExitTimeOut1 = TextBox4.Text Then '...


???

为什么下一个条件取决于文本?可以是任何东西.您应该了解您想要什么.甚至都不解释...了解自己& hellip;

您是否使用调试器?你应该的.



现在,您解释了您的比较.可怕!!!它不起作用.

条件


???

Why the next condition depends on Text? It can be anything. You should understand what do you want. Don''t even explain it… understand yourself…

Do you use Debugger? You should.



Now you explained what you compare. Dreadful!!! It won''t work.

The condition

If ExitTimeOut1 = TextBox4.Text Then '...


可能永远都不是真的,或者发生的可能性很小.在一个滴答中,时间可以更少,而在另一个时间中,更多.这不是很明显吗?

因此,您始终需要使用> =".

将文本转换为System.DateTime trigger,比较If System.DateTime >= trigger Then ''....

—SA


may never be true, or will happen with low probability. In one tick time can be less, another time more. Isn''t that obvious?

Therefore, you always need to use ">=".

Convert text to System.DateTime trigger, compare If System.DateTime >= trigger Then ''....

—SA


这篇关于使用vb.net使用控件单选按钮保存文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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