|
Here's and example from www.microsoft.com
For Each foundFile As String In My.Computer.FileSystem.GetFiles(
My.Computer.FileSystem.SpecialDirectories.MyDocuments,
Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, "*.dll")
Listbox1.Items.Add(foundFile)
Next
|
|
|
|
|
Hello there, this is my first time posting here discussion for help :3 - Be gentle please!
So my problem is copy and pasting data in multiple textboxes. So i have made 5 small textboxes (Serial Box), is there any possible way to make user copy data from all 5 instead of only 1 and same for pasting?
|
|
|
|
|
What are you "pasting" this information into? Your own application or some other app that you don't have control over?
|
|
|
|
|
It is possible, but you will need to write code to serialize the data from the Textbox es in some way (e.g. into XML or some similar formatted string). You can then send that to the ClipBoard [^]. On the paste operation you would get the data from the ClipBoard , deserialize it back to the five separate items and send each one to its Textbox .
Veni, vidi, abiit domum
|
|
|
|
|
10kbps wrote: So my problem is copy and pasting data in multiple textboxes. Easy anser; can't be done (but do read on!) You can paste text to the control that has focus, on the location of the cursor. If you want multiple pastes, you'd be doing them one after the other.
10kbps wrote: So i have made 5 small textboxes (Serial Box), is there any possible way to make user copy data from all 5 instead of only 1 and same for pasting? So, you got five textboxes, and want to paste a single string so that it gets divided over those five textboxes? That's different from pasting the same text to five textboxes
The first textbox typically has focus when I paste a serial number. Hence, I'd suggest splitting the string into five parts when it is pasted in the first textbox, and then to divide those parts over the correct textboxes.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I took this - Application Trial Maker[^] and started editing it to work online with database instead with .reg files and such, and in that Registration Dialog there are textboxes made as one component called serialbox, I want to get somehow to user can copy all at once ID and be able to paste serial all at once not to fill one box by another, any help about it maybe some code snippet or something? 
|
|
|
|
|
10kbps wrote: I want to get somehow to user can copy all at once ID and be able to paste serial all at once not to fill one box by another, any help about it maybe some code snippet or something? Here's something;
Imports System.Windows.Forms
Module Module1
Dim tb1 As TextBox
Dim tb2 As TextBox
Dim tb3 As TextBox
Sub Main()
Using f As New Form()
tb1 = New TextBox With {.Dock = DockStyle.Left, .MaxLength = 3}
tb2 = New TextBox With {.Dock = DockStyle.Left, .MaxLength = 5}
tb3 = New TextBox With {.Dock = DockStyle.Left, .MaxLength = 3}
f.Controls.AddRange(New Control() {tb3, tb2, tb1})
AddHandler tb1.KeyDown, AddressOf KeyDown
tb1.Focus()
f.ShowDialog()
End Using
End Sub
Public Sub KeyDown(sender As Object, e As KeyEventArgs)
If e.KeyCode = Keys.V And e.Control = True Then
e.Handled = True
DivideThisStringOverSomeTextBoxes(Clipboard.GetText)
End If
End Sub
Public Sub DivideThisStringOverSomeTextBoxes(someString As String)
Dim tempString As String = someString.Replace("-", "")
tb1.Text = tempString.Substring(startIndex:=0, length:=3)
tb2.Text = tempString.Substring(startIndex:=3, length:=5)
tb3.Text = tempString.Substring(startIndex:=8, length:=3)
End Sub
End Module Mind you, this will explode if you post a string of ten characters; you'd still have to add in that check, before the substring is done
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hy. i have the code from visual basic 6.0
i want change and convert from visual basic 6.0 to visual basic 2010.
this is my code.
i don't understand using syntax get and put in visual basic.
can you help me and explain to me about my code.
Private Sub Command3_Click()
Dim data As String
Dim x As Long
Dim y As Long
Dim z As Long
Dim pjg As Long
Dim ext As String
Dim encpjg As String
encpjg = FileLen(Text2.Text)
ext = Mid(StrReverse(Text2.Text), 1, 4)
ext = StrReverse(ext)
pjg = FileLen(Text1.Text)
FileCopy Text2.Text, Text2.Text & "_STEGO" & ext
x = FileLen(Text1.Text) Mod 10000
y = FileLen(Text1.Text) - x
Open Text1.Text For Binary Access Read As #1
Open Text2.Text & "_STEGO" & ext For Binary Access Write As #2
Put #2, FileLen(Text2.Text) + 1, ""
If pjg >= 10000 Then
For z = 1 To y Step 10000
data = Space$(10000)
Get #1, z, data
Put #2, , encrypt(data, Text5.Text)
Next
y = x
data = Space$(y)
Get #1, , data
Put #2, , encrypt(data, Text5.Text)
Put #2, , "|" & encrypt(encpjg, Text5.Text)
Else
data = Space$(pjg)
Get #1, 1, data
Put #2, , encrypt(data, Text5.Text)
Put #2, , "|" & encrypt(encpjg, Text5.Text)
End If
Close #2
Close #1
MsgBox "done!!" & vbCrLf & "file stego in " & Text2.Text & "_STEGO" &
ext, vbOKOnly, "stego"
End Sub
|
|
|
|
|
|
can you explain to me about using syntax put and get in visual basic 2010.
|
|
|
|
|
put and get in vb6 had been replaced with fileput and fileget. You may consult MSDN msdn.microsoft.com[^]
modified 19-Jan-14 3:05am.
|
|
|
|
|
This link may help you http://www.vb-helper.com/howto_2005_read_write_classic.html[^]
Private Const NUM_VALUES As Integer = 10
Const INTEGER_SIZE As Integer = 4
Private m_TextBoxes() As TextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
m_TextBoxes = New TextBox() {TextBox1, TextBox2, _
TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, _
TextBox8, TextBox9, TextBox10}
Dim file_name As String = GetFileName()
If System.IO.File.Exists(file_name) Then
Dim file_num As Integer = FreeFile()
FileOpen(file_num, file_name, _
OpenMode.Binary, OpenAccess.Read, _
OpenShare.Shared, INTEGER_SIZE)
Dim integers(NUM_VALUES - 1) As Integer
FileGet(file_num, integers)
FileClose(file_num)
For i As Integer = 0 To NUM_VALUES - 1
m_TextBoxes(i).Text = integers(i).ToString()
Next i
End If
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal _
e As System.Windows.Forms.FormClosingEventArgs) Handles _
Me.FormClosing
Dim file_name As String = GetFileName()
Dim file_num As Integer = FreeFile()
FileOpen(file_num, file_name, _
OpenMode.Binary, OpenAccess.Write, _
OpenShare.Shared, INTEGER_SIZE)
Dim integers(NUM_VALUES - 1) As Integer
For i As Integer = 0 To NUM_VALUES - 1
integers(i) = Val(m_TextBoxes(i).Text)
Next i
FilePut(file_num, integers)
FileClose(file_num)
End Sub
|
|
|
|
|
If you have access to Visual Studio 2005 you can do it in two steps. VS2005 has a converter from VB6 to VB2005, and 2010 has a converter from 2005.
Whilst that may be helpful if it is available to you as an option you still need to understand VB.NET as the converter will leave many things that have to be tweaked by hand.
|
|
|
|
|
What is the difference between using Sub_reports and grouping data in vb 2008?? Any links??
|
|
|
|
|
I'm trying to convert (from C++) a call to a DLL. I know that this requires a delegate etc but i am not getting very far as i believe i have a total misunderstanding of how delegates work with respect to pointers. The code i'm trying to convert is;
int __stdcall _RFID_Comms (char *sTx, char *sRx, WORD sRxSize, WORD timeout)
Parameters:
sTx - A pointer to a byte sized transmit buffer
sRx - A pointer to a byte sized receive buffer
sRxSize - Receive buffer size
timeout - The maximum length of time to wait in mS for incoming data.
I've converted this to;
Public Delegate Sub DelegateTagComms(ByVal sTx As IntPtr, ByVal sRx As IntPtr, ByVal sRxSize As UShort, ByVal timeout As UShort)
<DllImport("myCom.dll", CharSet:=CharSet.Unicode)> Public Function RFID_Comms(ByVal DTC As DelegateTagComms) As Integer
End Function
But i'm not sure how to use this conversion as many attempts cause a 'Fatal Exception'. As i'm working on a PDA program i cant get much from the error.
If someone can explian how delegates work with DLL calls it would be much apprieciated.
|
|
|
|
|
Why are you creating a delegate?
If the C++ code (I believe it is exported as C code, or else it will have a mangled name) is receiving the parameters like you are showing, then you should write the dll import of RFID_Comms receiving the parameters as you did to the delegate.
Ŧhat is, something like:
<DllImport("myCom.dll", CharSet:=CharSet.Unicode)> Public Function RFID_Comms(ByVal sTx As IntPtr, ByVal sRx As IntPtr, ByVal sRxSize As UShort, ByVal timeout As UShort) As Integer
In fact I am not pretty sure if VB.NET uses a different way of doing it, but in C# it will be pretty similar to this code that I just presented, but it will be declared as extern and static too.
|
|
|
|
|
Ok, that is what i had to start with;
<DllImport("myCom.dll", CharSet:=CharSet.Unicode)> Public Function RFID_Comms(ByVal sTx As IntPtr, ByVal sRx As IntPtr, ByVal sRxSize As UShort, ByVal timeout As UShort) As Integer
End Function
And the call....
sTx = Marshal.AllocHGlobal(100)
sRx = Marshal.AllocHGlobal(300)
sTx = StringToBSTR("RSD" & vbCr)
result = RFID_Comms(sTx, sRx, 3000, 1000)
lblOuput.Text = "Result: " & result
txtBxOutput.Text = PtrToStringUni(sRx)
AS i was getting a timeout error return code (result) i assumed i was going asbout it the wrong way.
Though i should have trusted myself as this code works (obtaining some version info from the DLL);
<DllImport("myCom.dll", CharSet:=CharSet.Unicode)> Function RFID_wGetVersion(ByVal s As IntPtr, ByVal size As UShort) As Integer
End Function
Dim memString As String
Dim addrPTr As IntPtr = Marshal.AllocHGlobal(40)
res = RFIDP1_wGetVersion(addrPTr, 40)
memString = PtrToStringUni(addrPTr)
lblOuput.Text = "Result: " & res
txtBxOutput.Text = memString
lblOuput.Refresh()
Marshal.FreeHGlobal(addrPTr)
You may have guessed but this prog reads an RFID tag. It is possible i'm missing another command (switch on and the like). I will persevere and recheck the other requisites for tag reading and post back. Thank you for confirming my initial thoughts and that I had got the function correct!
|
|
|
|
|
Delegate?? Calls to an external library do not require you to create a delegate.
Your declaration should look more like this:
Declare Function RFID_Comms Lib "myCom.dll" Alias "LibraryFunctionNameHere" (sTx As String, sRx As String, sRxSize As UShort, timeout As UShort)
It's very strange to see Short integers being used where they are. These may actually be Integers. If you're wrong, chances are good you'll get a message about unbalancing the stack.
|
|
|
|
|
Dave Kreskowiak wrote: It's very strange to see Short integers being used where they are.
In the 'screed' for the DLL and consequent C++ code it gave parameters as Char so i just decided to use UShort.
|
|
|
|
|
UShorts are not the same as chars!
|
|
|
|
|
Excuse my ignorance but what should i use?
|
|
|
|
|
|
Indeed - cant believe i missed that!
However, i am still no closer to solving my problem and have tried numerous variations of the function and parameters.
Will probably sleep on this and fresh start tomorrow!
|
|
|
|
|
Just in case someone comes across this post looking for answers themselves, i solved the main problem by actually turning the PCB board on with a software command
But to try and answer the pointers delegate question here are my thoughts; First of all it can be confusing when you first look at it - well for me at least. If you look at converting C++ to VB there is always talk about Delegates as VB doesn't really have pointers, ... or does it? I knew already (from previous project) that pointers work and i had used them and delegates and 'addressof method' and various other stuff to interact with hardware and a DLL, which at the time seemed complicated to me but it worked, so why should i worry. Also why should it be different this time? This is one reason i ruled out the passing of 'String' instead of 'IntPtr' in the Function. And as it turned out relying on the 'string' being a 'kind of pointer' was not the way to a solution. To be honest using VB to access hardware etc is not the norm i know, but i am VB orientated not C++
In the current project the hardware and DLL interact to respond to a command and send back info to an address in ASCII format. So in the end i just had to be simple;
Declare Function
Create send Pointer and allocate some memory
Convert Code to ASCII
Copy the ASCII command to the Pointer
Create receive pointer (sRx) and allocate some memory
Call Function
Finally Decode the returned ASCII, which requires copying the "unmanaged data" to "managed data" and then converting.
Public Declare Function RFIDP1_TagComms Lib "myCom.dll" Alias "RFIDP1_TagComms" (ByVal sTx As IntPtr, ByVal sRx As IntPtr, ByVal sRxSize As Integer, ByVal timeout As Integer) As Integer
tagRead = "SRD"
Dim code() As Byte = System.Text.Encoding.ASCII.GetBytes(tagRead)
Dim codeLen As Integer = code.Length
result = PwrCtrl(1, True)
Threading.Thread.Sleep(500)
txtBxOutput.Text = "Module On"
Dim pointer As IntPtr = Marshal.AllocHGlobal(codeLen)
Marshal.Copy(code, 0, pointer, codeLen)
Dim sRx As IntPtr = Marshal.AllocHGlobal(127)
result = RFIDP1_TagComms(pointer, sRx, 127, 500)
If result = 0 Then
lbltagResult.Text = "Tag Read"
Else
lbltagResult.Text = result
End If
deCode(sRx)
Public Sub deCode(ByVal addr As IntPtr)
Dim managedArray2(127) As Byte
Marshal.Copy(addr, managedArray2, 0, 127)
Dim enc As New System.Text.ASCIIEncoding()
txtBxTN.Text = enc.GetString(managedArray2, 0, 18)
End Sub
So overall 'easy when you know how' 
|
|
|
|
|
Is there any way to pass the value to scheduled task(.vbs file scheduled by same script) from vb script ?
|
|
|
|
|