我如何比较什么是什么 [英] How do I compare what was to what is

查看:82
本文介绍了我如何比较什么是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我被要求在屏幕上添加审核。



我们在vb中有一个显示网格的应用程序。第一列是链接按钮。单击LB时,将显示详细信息区域,其中所有字段整齐排列。



在网格的rowcommand事件中,我可以捕获所选行并保存在一个会话中,我可以得到之前的数据。



用户进行更改后,我想我需要保存字段数据并调用方法来做比较使用保存的会话数据作为之前和显示(更改)的数据作为之后。



我被简要指示使用集合和a For Each Next例程。



问题是我对这一切都有点新意,不知道怎么把它们放在一起。 />


我尝试了什么:



我在网上研究并很快发现这是其他人遇到的一项艰巨的任务,但他们所做的比我的简单网格更复杂。我无法找到接近我的情况的东西,但必须有一个简单的方法来实现这一点。

Hi,

I've been asked to add auditing to a screen.

We have an application in vb that displays a grid. The first column is a link button. When a LB is clicked, a details area is displayed with all the fields neatly organized.

In the rowcommand event for the grid I can capture the row selected and save it in a session so I can have the "before" data.

After the user makes changes, I figure I need to save the field data and call a method to do the comparing using the saved session data as the "before" and the displayed (changed) data as the "after".

I was briefly instructed to use a collection and a For Each Next routine to do it.

The problem is I'm somewhat new to all this and don't know how to put it all together.

What I have tried:

I've researched online and soon discovered this to be a daunting task that others have encountered but what they were doing was more complicated than my simple grid. I couldn't find something close to my situation but there must be an easy way to accomplish this.

推荐答案

我所理解的似乎你想看到的如果发生了变化或者没有变更,那么这就是你应该做的事情:

首先你必须创建包含旧事物(如文本)的字符串和新字符串

现在把信息放在数据库的一个文本框中(我假设你知道怎么做,如果我错了,那就用这个代码:

for what I've understood it seems like you want see if something changed or not so if this is it then this is what you should do:
first you have to create string that contains the "old" thing(like text) and the new string
Now put the information in one textbox from the database(I'm assuming you know how to do it, if i'm wrong then use this code:
Dim Str As String
Try
   Str = "update tabel1 set ID="
   Str += """" & TextBox1.Text & """"
   Str += " where ID="
   Str += TextBox1.Text.Trim()
   provider.Open()
   Cmd = New OleDbCommand(Str, provider)
   Cmd.ExecuteNonQuery()
   provider.Close()
   Catch ex As Exception
End Try






)

public sub Form1
dim Str_Old As String
dim Str_Old As String 



那么使用它们就像这样简单:


Then to use those is as easy as :

Private Sub Form1 (...) handles Form1.load
Str_Old = TextBox1.Text ' Original data like if you have the things loading on startup to a textbox

Private sub Check_Changed
StrNew = TextBox1.Text
if Str_New <> Str_Old then ' The "<>" means different
' Your code here (The one that is suposed to act if something changed)
Else
' Your code here (The one that is suposed to act if nothing changed)
End If



现在打电话这很简单,如果你想在按下按钮时这样做,那就把它放到按钮上:


Now to call this is easy if you want this to act when a button is pressed then just put this into the button:

Check_Changed()



现在你很高兴

免责声明:我刚才解释了一切因为你说你是一个初学者。


Now you are good to go
Disclaimer: I just explained everything step-by-step because you say you are a beginner.


这篇关于我如何比较什么是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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