Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag and Drop Editing on mskedit

Status
Not open for further replies.

StormbringerX

Programmer
Dec 14, 2000
102
0
0
US
Hey gang,

I hope there's a simple solution but I can't see it...

I have a form with a mskedbox. This box is the key field on the form and once the data is validated the entire record is found and loaded onto the form. I also have a search button that loads the search results into a listview. The drag and drop from the listview to the mskedbox is working fine. The problem is: when dropping onto the box, the drop occurs wherever the user is pointing to in the mskedbox. Which means that unless they are very careful, they can drop the information into the middle of the field and it gets truncated. What I'm looking for is a way to left justify anything that gets dropped into the mskedbox. Is there some way to capture the data BEFORE it gets dropped so that I can manually do what I need to do? Is there some function or procedure that I'm missing?

Thanks for any help you can give...
Dave
 
Hi,

I don't get the problem you describe. I have to be careful with the format AND length (padding the lenght with underscores) but it is not sensitive to WHERE the drop is done.

Here is my code ...

Private Sub MaskEdBox1_OLEDragDrop(Data As MSMask.DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim str As String
On Error GoTo BADFORMAT
If Data.GetFormat(vbCFText) = True Then
str = Data.GetData(vbCFText)
If Len(str) > Len(MaskEdBox1.Mask) Then
MsgBox "Text too long : " & str & " > " & MaskEdBox1.Mask
Else
While Len(str) < Len(MaskEdBox1.Mask)
str = str & &quot;_&quot;
Wend
MaskEdBox1.Text = str
End If
End If
Exit Sub
BADFORMAT:
MsgBox &quot;Bad Format : &quot; & Data.GetData(vbCFText) & &quot; does not match &quot; & MaskEdBox1.Mask
End Sub

Best wishes,

JonathanC
 
Thanks for the reply, Jonathan. The problem seems to be in the mask itself. Meaning if I remove the mask then the drop works fine. But with the mask (which is: AA-AA-AA-A-AAA) the drop occurs WHEREVER they release the mouse button. For instance, if the actual data is 0101010000 and they drop between the 1st and 2nd dash, then the mskeditbox contains __-01-01-0-100 and the rest is truncated. Does that make sense?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top