In a VB6 project, I would like to be notified when an edit control (text field) has been updated (i.e. : character string has been added by a user into the text field).
I did not find any documentation on the different events which can be catched for an edit MFC control.
Thanks in advance.
Its the _Change event. However, I personally do not like this event since it is notoriously unreliable.
Private Sub txtYourTextFieldControl_Change()
' some code here
End Sub
* edit *
We are talking about VB6 textbox, correct? I am not sure what MFC has to do with this.
Related
So I mostly use Microsoft Excel for a lot of my work and the most "Programming" I do is writing basic logical functions in excel.
I am setting up a windows form in Visual Studio 2013 and I want to the end user to be able to be able to confirm that the data they input into TEXTBOX1 matches what is in TEXTBOX2.
So normally in excel I can just write =IF(C2=D2,"Yes","No")
So basically I want to be able to input data in the carton field and then in the label field and if it matches I want it to say yes in the text box at the bottom.
I tried writing
If CartonBarcode = LabelBarcode Then
PartCheck = "Yes"
Else : PartCheck = "No"
End If
but that hasn't worked - I am very new to VB so please be gentle.
Eventually I also want to be able to append the scanned data (If the two text boxes match) into an excel spreadsheet.
Thanks in advance for all your help =)
Thanks for your help Mark - that makes a lot of sense.
I added this IF Statement to the PartCheck text box but it doesn't seem to display Yes or No regardless of what I put in.
It now throws two errors (look to be the same error on each line.)
Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'
Any further help you can provide would be fantastic
Screenshot of errors
I then changed PartCheck = "Yes" to PartCheck.Text = "Yes" and it runs but then nothing displays in the PartCheck Text Box
In WinForms, TextBox and other GUI components (e.g. Label, Button) are objects, with properties and methods to interact with them. If you want to compare the text that has been entered into two TextBox objects, you will need to compare their Text properties. e.g.
Update
Updated code below based on your updated question. You are correct that you need PartCheck.Text = "Yes" to set it correctly. Your current issue is when you are performing the check. You are handling the TextChanged event for your PartCheck TextBox, but your logic should really be triggered when either the CartonBarcode or LabelBarcode text is changed. You can either have TextChanged handlers for both of those TextBox controls, and call a common subroutine to perform the check, or have a common TextChanged handler, as shown below:
Private Sub Barcode_TextChanged(sender As Object, e As EventArgs) _
Handles CartonBarcode.TextChanged, LabelBarcode.TextChanged
If CartonBarcode.Text = LabelBarcode.Text Then
PartCheck.Text = "Yes"
Else
PartCheck.Text = "No"
End If
End Sub
Sorry. i am officially new in Visual Basic.
I have created a TextBox in my form. In "View Code" i want to access the Text attribute
(I mean TextBox.Text)
,but the object only gives me these 4: Count,Item,LBound,UBound
Maybe you're changing the Index property instead of the TabIndex property so that it would become a control array thus UBound, LBound, Count and Item properties are present.
And i suspect you are using Visual Basic 6 instead of VB.Net.
See link here the VB6 has Index property that is for Control Array.
My guess, without seeing your code is that your syntax is somehow interacting with an array, try this code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TextBox1.Text = "Hello World"
End Sub
End Class
Note: The above code represents the default names for a Form, a new TextBox dragged and dropped onto the designer inside of the form's Load event handler.
Are you possibly copying and pasting a textbox rather than double clicking the object in the toolbox. If you look in the name of the object in the properties window you would see txtName(0)
I'm having difficulty trapping a programmatically triggered click event on a hidden button control from a ASP.NET MVC 4 web app inside a VB6 thick client (which is using a web browser control). I'm able to trap the click event itself using the following:
Private WithEvents WebDoc As HTMLDocument
Private Function WebDoc_onclick() As Boolean
Select Case WebDoc.activeElement.iD
Case "A"
Do something
Case "C"
Do something else
End Select
WebDoc_onclick = True
End Function
And this works just fine if the control is visible. But if the control is invisible:
<div class="HideBtnDiv">
<input id="C" name="NoItems" type="button" class="BtnDiv" style="display:none"/>
</div>
and I try to trigger a programmatic click via one of the following:
$("#C").('click');
$("#C").trigger('click');
$("#C").triggerhandler("click");
$("#C").focus();
$("#C").trigger('click');
I'm getting an empty string for the "id" attribute and as a result I can't distinguish which button was clicked. This button serves no purpose other than to indicate to the VB6 app that a certain criteria has been met and that's the reason why I need it to be hidden. Does anyone have any idea why the id is getting stripped? Or is there any other way to communicate back to the client?
I've also tried filtering by element style using
Select Case WebDoc.activeElement.Style
Case "display:none"
Do something else
End Select
but it came back as "[Object]" so no luck there either. Please let me know if there is a way around this.
Thanks,
Lijin
You seem to have tried several ways of dynamically triggering the click event, but did you try the most obvious way:
$("#C").click();
???
But here is what I would do:
1- Make all of your buttons visible, by removing "display:none" from their style
2- Wrap the buttons you want to hide in a new DIV
3- Set "display:none" style in the newly created DIV
4- You can then trigger the .click() event of any button even if not visible by calling $(id).click();
Thanks, Ahmad. Actually I meant .click() not .('click'). Sorry about that.
Anyway, I tried your suggestion and made the button visible and set the style of the wrapping div to display:none but the id attribute was still coming through as an empty string.
However, I did figure out another way to get this to work. If I keep the wrapping div and button as visible and then focus and click when the condition is met and then do a hide(), my problem is resolved!
$("#C").focus();
$("#C").trigger('click');
$("#C").hide();
The button doesn't get displayed and VB6 still passes the id on the click event. The weird thing is it requires the focus() call to still be made. Without it, I'm back to square one. Not sure if this is a bug.
Okay, this is a bit of a tricky one...
I am programming an add-in for MS Outlook 2007, using VS 2010 and VSTO, and VB.NET. My goal is to prompt the user to print off emails that they receive from certain email addresses. (This would be done with a simple MsgBox.)
Specifically, I would like the prompt the user when they are done reading the email. My concept is that it should work similarly to the "Read Receipt" functionality in Outlook. (You know, those annoying things..."The sender has requested a receipt that you have read this email blah blah")
So, the user reads the email, and then when they go to close the Inspector (or change focus to a different item if they are in Explorer view) the MsgBox pops up. I have noticed that the timing on this matches when the email becomes "read".
I have been chasing this across Google and MSDN and tutorial websites for a few days, here's what I've found:
Round 1:
The Mailitem object has an UnRead property, and it also has a PropertyChange event. I can use AddHandler for PropertyChange on every Mailitem in the Inbox, tying them into a single Subroutine that checks the argument of the PropertyChange event to make sure it's UnRead. Seems fairly workable, except that PropertyChange doesn't pass the calling object's identity, so I have no way of knowing what email in the Inbox just lost "unread" status.
In fact, none of the Mailitem events seem to pass their identity, probably because someone (MS I guess) assumes that you have a direct pointer to the Mailitem object in the first place. So this route doesn't seem to work.
Round 2:
I can grab all of the Mailitems in the Inbox into a collection, then restrict them to just the Unread ones.
Dim inbox As Outlook.MAPIFolder = Nothing
Dim WithEvents unreadItems As Outlook.Items
inbox = Me.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
unreadItems = inbox.Items.Restrict("[Unread]=true")
Since unreadItems was Dimmed WithEvents, I could write a Sub to Handle unreadItems.ItemRemove, which would work fine. But the ItemRemove event has no object argument! Doh!
Round 3:
Let's say I do the opposite: I get the inbox contents and restrict to [Unread]=false, then use the .ItemAdd event. This would work to a degree, except that it would theoretically call whenever an "[Unread]=false" item was dumped into the Inbox by the user from any folder, not just a change from the Unread to Read group within the Inbox. So, unless I'm misunderstanding something here, also not an option.
Round 4:
Now, something I also thought of was simply Dimming the Inbox items collection WithEvents and going off the .ItemChange event, but this event doesn't really specify what changed about the object, so no dice.
In closing, I'm pretty darn stumped with this. I am very close to backing down from my goal. A lame alternative is to alert the user when they receive an email from one of the designated addresses (because I believe the Application.NewMail event won't give me any hassle). But then, I will have to simply alert the user--I won't prompt them to print an email they haven't even read yet.
This alternative is undesirable and I figured that I would present my problem for inspection and suggestion.
-Matt
P.S. I'm coming from making iPad apps with Objective-C, where I'm building most of the object hierarchy myself...it's weird to have to deal with COM objects that have such limitations.
I'm not quite sure how you want your UI to behave, because it's not quite clear when the user is done reading their email. One way to look at it is that they are done when they have looked at it, meaning that the inspector window has shown the mail and the user is switching to another one. To catch that, you would probably be best off watching events from the inspector, not the mail items.
The other way to look at it is that a mail is read whenever it is marked as Read. Be aware that the user may actually turn off the option to mark items as read automatically! This can be done in Tools->Options->Other->Reading pane, like this:
Also, the user may select items and mark them as read manually, so you need to think about what you want do in that case.
If you want to watch for the change in "read" property of the MailItem, you are very close in round 1. The thing you need to add is that you shouldn't tie all of your handlers to a single subroutine in a single object instance. Instead, you can create your own class, something like this (C# code):
class ItemWatcher
{
// The Outlook mailitem to watch for
private Microsoft.Office.Interop.Outlook.MailItem itemBeingWatched = null;
public ItemWatcher(Microsoft.Office.Interop.Outlook.MailItem item, Form1 parentForm)
{
itemBeingWatched = item;
itemBeingWatched.PropertyChange += new Microsoft.Office.Interop.Outlook.ItemEvents_10_PropertyChangeEventHandler(itemBeingWatched_PropertyChange);
}
void itemBeingWatched_PropertyChange(string Name)
{
// Respond to property <Name> in the object itemBeingWatched having changed
}
}
Then you need to create a collection of your ItemWatcher classes and set them to watch your emails.
Note that you will also need to watch for items you need to add/remove from your collection of watched items, when a new mail arrives or an old mail is deleted/moved.
I am trying to disable a field, i.e. grey it out and not allow the user to select it. To achieve this effect I am currently calling
crmForm.all.new_attribute1.disabled = true;
crmForm.all.new_attribute2.Disabled = true;
The Disable, with a capital D, makes the field grayed out but the user can still put the cursor in that field or tab to it.
The disable, with a little d, makes the field unavailable to the cursor and via tab, but gives no visual indication that it can't be interacted with.
Is there a better way to do this, one call that will achieve similar results or am I stuck having both there?
Using "Disabled" property should work.
You can try putting this code in OnLoad event of Account entity (don't forget to enable Event and Publich entity!):
crmForm.all.accountnumber.Disabled = true;
And "Account Number" will be blocked and greyed as seen in this picture:
(source: vidmar.net)
You are talking about readOnly and disabled.
A great article was posted http://customerfx.com/pages/crmdeveloper/2006/03/06/readonly-and-disabled-fields.aspx ... maybe this could help.