|
I am very new to Visual Basic 6, so forgive me if this is not the appropriate forum for this question.
I am building a form that has a text box that will hold hexadecimal data. I want to be able to take this data and display it seperate boxes of 2 characters. I know this can be done using Left(textName, 2) and also Mid(textName, 3, 2) but I can't seem to make it work.
Example: Text Box with this data: 22AB3F3202
That would yield text boxes with this: 22 AB 3F 32 02
I hope I made what I need clear and that someone can help me.
Thank you!
|
|
|
|
|
While there are a number of different ways you can do this, here is just a quick example:
Dim str, buff As String
str = Me.TextBox1.Text
Do While Len(str)
buff = Left(str, 2)
ListBox1.AddItem (buff)
str = Right(str, Len(str) - 2)
Loop
You can obviously remove the listbox instruction, this is only an example. Hope this helps.
-Nick Parker
|
|
|
|
|
plz post some code so we can help
|
|
|
|
|
I finally got it to work using the following code. It's probably not the most efficient code, so if there is a better way, please let me know.
Private Sub txtCMD_Change()
Dim Length As String
Dim Hash As String
Dim Code2 As String
Dim Code3 As String
Dim Code4 As String
Dim Code5 As String
Dim Code6 As String
Dim Code7 As String
Dim Code8 As String
Dim Code9 As String
Dim Code10 As String
Dim Code11 As String
Dim Code12 As String
Dim Code13 As String
Dim Code14 As String
Dim Code15 As String
Dim Code16 As String
Dim Code17 As String
Dim Code18 As String
Dim Code19 As String
Dim Code20 As String
Dim Code21 As String
Dim Code22 As String
Dim Code23 As String
Dim Code24 As String
Dim Code25 As String
Dim Code26 As String
Dim Code27 As String
Dim Code28 As String
Dim Code29 As String
Dim Code30 As String
Dim Code31 As String
Dim Code32 As String
Dim Code33 As String
Dim Code34 As String
Dim Code35 As String
Dim Code36 As String
Dim Code37 As String
Dim Code38 As String
Dim Code39 As String
Dim Code40 As String
Dim Code41 As String
Dim Code42 As String
Dim Code43 As String
Dim Code44 As String
Dim Code45 As String
Dim Code46 As String
Dim Code47 As String
Dim Code48 As String
Dim Code49 As String
Length = txtCMDLength.Text
Hash = txtHashRange.Text
Code2 = Hex2.Text
Code3 = Hex3.Text
Code4 = Hex4.Text
Code5 = Hex5.Text
Code6 = Hex6.Text
Code7 = Hex7.Text
Code8 = Hex8.Text
Code9 = Hex9.Text
Code10 = Hex10.Text
Code11 = Hex11.Text
Code12 = Hex12.Text
Code13 = Hex13.Text
Code14 = Hex14.Text
Code15 = Hex15.Text
Code16 = Hex16.Text
Code17 = Hex17.Text
Code18 = Hex18.Text
Code19 = Hex19.Text
Code20 = Hex20.Text
Code21 = Hex21.Text
Code22 = Hex22.Text
Code23 = Hex23.Text
Code24 = Hex24.Text
Code25 = Hex25.Text
Code26 = Hex26.Text
Code27 = Hex27.Text
Code28 = Hex28.Text
Code29 = Hex29.Text
Code30 = Hex30.Text
Code31 = Hex31.Text
Code32 = Hex32.Text
Code33 = Hex33.Text
Code34 = Hex34.Text
Code35 = Hex35.Text
Code36 = Hex36.Text
Code37 = Hex37.Text
Code38 = Hex38.Text
Code39 = Hex39.Text
Code40 = Hex40.Text
Code41 = Hex41.Text
Code42 = Hex42.Text
Code43 = Hex43.Text
Code44 = Hex44.Text
Code45 = Hex45.Text
Code46 = Hex46.Text
Code47 = Hex47.Text
Code48 = Hex48.Text
Code49 = Hex49.Text
Length = UCase(Mid(txtCMD, 3, 2))
txtCMDLength = Length
Hash = UCase(Mid(txtCMD, 11, 4))
txtHashRange = Hash
Code2 = UCase(Mid(txtCMD, 3, 2))
Hex2 = Code2
Code3 = UCase(Mid(txtCMD, 5, 2))
Hex3 = Code3
Code4 = UCase(Mid(txtCMD, 7, 2))
Hex4 = Code4
Code5 = UCase(Mid(txtCMD, 9, 2))
Hex5 = Code5
Code6 = UCase(Mid(txtCMD, 11, 2))
Hex6 = Code6
Code7 = UCase(Mid(txtCMD, 13, 2))
Hex7 = Code7
Code8 = UCase(Mid(txtCMD, 15, 2))
Hex8 = Code8
Code9 = UCase(Mid(txtCMD, 17, 2))
Hex9 = Code9
Code10 = UCase(Mid(txtCMD, 19, 2))
Hex10 = Code10
Code11 = UCase(Mid(txtCMD, 21, 2))
Hex11 = Code11
Code12 = UCase(Mid(txtCMD, 23, 2))
Hex12 = Code12
Code13 = UCase(Mid(txtCMD, 25, 2))
Hex13 = Code13
Code14 = UCase(Mid(txtCMD, 27, 2))
Hex14 = Code14
Code15 = UCase(Mid(txtCMD, 29, 2))
Hex15 = Code15
Code16 = UCase(Mid(txtCMD, 31, 2))
Hex16 = Code16
Code17 = UCase(Mid(txtCMD, 33, 2))
Hex17 = Code17
Code18 = UCase(Mid(txtCMD, 35, 2))
Hex18 = Code18
Code19 = UCase(Mid(txtCMD, 37, 2))
Hex19 = Code19
Code20 = UCase(Mid(txtCMD, 39, 2))
Hex20 = Code20
Code21 = UCase(Mid(txtCMD, 41, 2))
Hex21 = Code21
Code22 = UCase(Mid(txtCMD, 43, 2))
Hex22 = Code22
Code23 = UCase(Mid(txtCMD, 45, 2))
Hex23 = Code23
Code24 = UCase(Mid(txtCMD, 47, 2))
Hex24 = Code24
Code25 = UCase(Mid(txtCMD, 49, 2))
Hex25 = Code25
Code26 = UCase(Mid(txtCMD, 51, 2))
Hex26 = Code26
Code27 = UCase(Mid(txtCMD, 53, 2))
Hex27 = Code27
Code28 = UCase(Mid(txtCMD, 55, 2))
Hex28 = Code28
Code29 = UCase(Mid(txtCMD, 57, 2))
Hex29 = Code29
Code30 = UCase(Mid(txtCMD, 59, 2))
Hex30 = Code30
Code31 = UCase(Mid(txtCMD, 61, 2))
Hex31 = Code31
Code32 = UCase(Mid(txtCMD, 63, 2))
Hex32 = Code32
Code33 = UCase(Mid(txtCMD, 65, 2))
Hex33 = Code33
Code34 = UCase(Mid(txtCMD, 67, 2))
Hex34 = Code34
Code35 = UCase(Mid(txtCMD, 69, 2))
Hex35 = Code35
Code36 = UCase(Mid(txtCMD, 71, 2))
Hex36 = Code36
Code37 = UCase(Mid(txtCMD, 73, 2))
Hex37 = Code37
Code38 = UCase(Mid(txtCMD, 75, 2))
Hex38 = Code38
Code39 = UCase(Mid(txtCMD, 77, 2))
Hex39 = Code39
Code40 = UCase(Mid(txtCMD, 79, 2))
Hex40 = Code40
Code41 = UCase(Mid(txtCMD, 81, 2))
Hex41 = Code41
Code42 = UCase(Mid(txtCMD, 83, 2))
Hex42 = Code42
Code43 = UCase(Mid(txtCMD, 85, 2))
Hex43 = Code43
Code44 = UCase(Mid(txtCMD, 87, 2))
Hex44 = Code44
Code45 = UCase(Mid(txtCMD, 89, 2))
Hex45 = Code45
Code46 = UCase(Mid(txtCMD, 91, 2))
Hex46 = Code46
Code47 = UCase(Mid(txtCMD, 93, 2))
Hex47 = Code47
Code48 = UCase(Mid(txtCMD, 95, 2))
Hex48 = Code48
Code49 = UCase(Mid(txtCMD, 97, 2))
Hex49 = Code49
End Sub
|
|
|
|
|
you could cut down with the string , also you could make an array of your textboxes , then you could use something like this :
Vb6:
<font color="blue">Private</font> <font color="blue">Sub</font> Command1_Click() <br> <font color="blue">Dim</font> code(2 To 49) <font color="blue">As</font> <font color="blue">String</font>, x <font color="blue">As</font> <font color="blue">Long</font> <br> <font color="blue">Dim</font> txthx(2 To 49) <font color="blue">As</font> <font color="blue">String</font> <br> <font color="blue">Dim</font> tb <font color="blue">As</font> TextBox <br> <br> <font color="blue">For</font> x = 2 <font color="#0000FF">To</font> 49 <br> <font color="blue">For</font> <font color="blue">Each</font> tb <font color="blue">In</font> <font color="#0000FF">Controls </font><br> <font color="#0000FF">If</font> tb.Name = txthx(x) <font color="#0000FF">Then </font><br> tb.Text = code(x) <br> <font color="blue">End</font> <font color="#0000FF">If </font><br> <font color="blue">Next</font> <br> <font color="blue">Next</font> <br> <br> <font color="blue">End</font> <font color="blue">Sub</font> <br>
that would cut out a lot of code
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
That looks like it would save a lot of code, but I'm not sure how to use it to get the results I need. Am I correct that this is attached to a command button?
|
|
|
|
|
I can't believe I haven't been able to find any way to clear the console
screen in vb.net.
All I want is to clear the console screen just like issuing a cls command
at a command prompt.
Does anyone out there know how this is done?
|
|
|
|
|
You could try P/Invoke'ing the FillConsoleOutputCharacter function. See MSDN Library for details.
|
|
|
|
|
Thank you!
I found it in the MSDN libraries url is http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b319239
if anyone is interested. A WHOLE lot of work just to clear the console,
I can't believe they didn't include this functionality in the Console
namespace.
Oh well, maybe next time. Thanks again!
|
|
|
|
|
If it's any consolation (no pun intended), there's no function for this that I can see in the C runtime library either - I was going to look at the implementation if there was one.
In case anyone else wants that article, clickety[^].
|
|
|
|
|
|
I have two datatables which are populating from two different tables of two different databases. I want to get all the records of first datatable which are not in 2nd datatable. I ‘m using the following piece of code.
odr = oDs.Tables(0).Select("Sno = (SELECT SNO FROM " + Convert.ToString(oDataSetChanges.Tables(0)) + ")")
or this one
odr = oDs.Tables(0).Select("Sno NOT IN (SELECT " + Convert.ToString(oDataSetChanges.Tables(0).Columns("SNO")) + " FROM " + Convert.ToString(oDataSetChanges.Tables(0)) + ")")
or I tried the following code as well
oDv1.RowFilter = "Sno NOT IN (SELECT SNO FROM " + Convert.ToString(oDv2.Table) + ")"
where SNO are the primary key columns of both tables but by using all these code I got the same syntax error that is
Message "Syntax error: Missing operand after 'SNO' operator."
Kindly help me in this reagard ASAP
Thanx in advance
|
|
|
|
|
I don't think this is possible. The Select() method doesn't have the full power of SQL - it can only define fairly simple filter expressions.
You can set up relations between tables in a DataSet with the Relations property to set up a parent/child table relationship; however, I don't think you'll be able to do this in this case - I don't think it'll help.
I'd recommend - assuming that your data is coming from at least one SQL Server - setting up a link between the two servers (so that server A can see the table on server B) and performing the difference operation in a stored procedure. You can then use the full power of SQL.
--
Mike Dimmick
|
|
|
|
|
hi mike
thanx for ur reply. i used ur opinion i.e linked both the sql servers via enterprise manager now tell me plz how much it will take effect on the execution performance with respect to time than that of disconnected datasets.
regards
Aamir
|
|
|
|
|
SQL Server uses OLE DB internally to access and manipulate tables of data. It's optimised for manipulating data sets.
As long as the connection between the two servers is at least as fast as the connection between the client and the two servers, you shouldn't see any difference.
Indeed it might even be quicker than two datasets, because SQL Server will tend to fetch rows from the linked database and its local database asynchronously, whereas you typically fill your local datasets synchronously, waiting for the first to complete before asking for the second. (I believe you could do this yourself by using BeginInvoke to perform both operations on the thread pool, then wait for both IAsyncResult.AsyncWaitHandle s to be signalled).
Your experience may vary and, as always with performance, you should measure it rather than guessing. Query Analyzer can show you the query execution plan and the time taken to execute the query.
If the link between the servers is slow (perhaps they're located far apart, geographically?) you could consider replication instead.
|
|
|
|
|
thnx for replying
yes in my case the servers are far apart like for example one in US n other in SingaPore so can u tell me how i use replication as i have no idea of replication. i'll b very thankful to u
regards
aamir
|
|
|
|
|
I could regurgitate a whole load of documentation here, but I won't: I'll just direct you to SQL Server Books Online[^] - note, this link is to a download, not online documentation.
In the Contents tab, go to Replication.
Snippet:
When to Use Replication
With organizations supporting diverse hardware and software applications in distributed environments, it becomes necessary to store data redundantly. Moreover, different applications have different needs for autonomy and data consistency.
Replication is a solution for a distributed data environment when you need to:- Copy and distribute data to one or more sites.
- Distribute copies of data on a scheduled basis.
- Distribute data changes to other servers.
- Allow multiple users and sites to make changes then merge the data modifications together, potentially identifying and resolving conflicts.
- Build data applications that need to be used in online and offline environments.
- Build Web applications where users can browse large volumes of data.
- Optionally make changes at subscribing sites that are transparently under transactional control of the Publisher.
If you always want the latest data available to your client, and cannot stand any stale data, stick with linked servers. Otherwise replication should produce less traffic between servers.
|
|
|
|
|
Not sure about you guys but I often need to paste the output of console apps into emails, documents, and the like so what I normally do is:
dir /s > test.txt
Then open up "test.txt" and then copy and paste the contents to wherever I need it and then delete "test.txt" now this is a pain and I thought there has to be a better way. So I wrote a utility in VB.Net to solve the problem. I would have written this as an article but the .NET Framework has made this so simple the article would be too short
1. Create a new console application
2. Add a Reference to System.Windows.Forms
3. Paste this code into the Main function
Dim strInput As String
strInput = Console.In.ReadToEnd()
Windows.Forms.Clipboard.SetDataObject(strInput, True)
4. Compile and put the resulting .exe in your path
Now all you need to do is:
dir /s | YourProgramName.exe
Then go into your email, document, etc. and paste... the program has captured the console output and put it into the clipboard. Hope you guys find this helpful.
|
|
|
|
|
I finishing up some code I wrote for a multi server chat that uses TCP/IP and Telnet, and I was wondering if there was any interest for it on this site. Its writen in VB.net and its completely convertable into a MUD, data pipe, or FTP system. If there is enough interest I will post all of the source. I hope you guys like class files, cause darn near the whole thing is made up of em
|
|
|
|
|
Maybe you should submit it as an article. I'd certainly be interested in reading it.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
This would definitely interest me...
|
|
|
|
|
Hi, Does anyone know how to use the plug-ins api available with VB6. I can't find any documentation for it or anything. Thanks in advance
Allan
|
|
|
|
|
Hi,
I'm trying to setup my VB executable to pull in a parameter when the executable is called.
For example: MessageOperator.exe /B
Here is what I've setup so far:
Public Class MessageOperator
Public Shared Sub Main(Optional ByVal strOption As String = "A")
if strOption = "A" then
...
else
...
end if
At compile time I'm getting the following error:
No accessible 'Main' method with an appropriate signature was found in 'MessageTheOperator'.
I'm either doing something stupid or heading in the right direction, but missing one small item.
Anyone have a suggestion?
Kevin
|
|
|
|
|
In VB, the command line parameters are read from a function (like "Command"). They are not passed into the Main as parameters. Remove the parameter from Sub Main and re-code it to read the parameter from the Command function and you should be all set.
Mike Mestemaker
|
|
|
|
|
Thanks,
I did the following and it worked like a charm:
Dim strMode As String = Microsoft.VisualBasic.Command()
If strMode = "Report" Then
MsgBox("Print Report")
Else
MsgBox("Display Form")
End If
The program is executed:
program.exe Report
Thanks again!! Kevin
|
|
|
|
|