|
this is the decoding function,its working
Public Function sHexDecode(ByVal sData As String) As String<br />
Dim iChar As Integer<br />
Dim sOutString As String<br />
Dim sTmpChar As String<br />
<br />
<br />
For iChar = 1 To Len(sData) Step 2<br />
If Mid(sData, iChar, 2) = "00" Then<br />
'sTmpChar = vbNullString<br />
oCP.Write(Chr("&H" & (1 - 1)))<br />
GoTo skipDecode<br />
End If<br />
<br />
sTmpChar = Chr("&H" & Mid(sData, iChar, 2))<br />
skipDecode:<br />
sOutString = sOutString & sTmpChar<br />
<br />
Next iChar<br />
sHexDecode = sOutString<br />
'Mod By TC Kua<br />
TextBox1.Text = ""<br />
TextBox1.Text = sHexDecode<br />
End Function
this is the part to display the output
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
Try<br />
'Mod by TC Kua 21st Feb 2008 <br />
Call sHexDecode(txtHex.Text)<br />
oCP.Write(Encoding.ASCII.GetBytes(Me.TextBox1.Text)))))<br />
oCP.Write(Chr("&H" & (1)))<br />
Catch ex As Exception<br />
' Warn the user.<br />
MessageBox.Show("Unable to write to comm port")<br />
Finally<br />
<br />
End Try<br />
End Sub
|
|
|
|
|
Is this VB.NET ? Don't use stuff like 'Mid', use the proper .NET stuff.
pandapatin wrote: GoTo skipDecode
This use of Goto is just plain lazy and it makes your code hard to read. Don't use goto if you don't need to.
pandapatin wrote: If Mid(sData, iChar, 2) = "00" Then
What if the string has an odd number of characters ?
Given that your original complaint is about what happens when the code hits 00, and given that you have a special case for this, can't you make it do whatever you like ?
pandapatin wrote: sTmpChar = Chr("&H" & Mid(sData, iChar, 2))
I guess you came from VB6. Please try to learn VB.NET. If MS had their way, this code would not work, all this VB6 stuff was originally to be removed. The string class as all the methods you need for this stuff.
pandapatin wrote: TextBox1.Text = ""
TextBox1.Text = sHexDecode
Plain bizarre. Why set it twice in two lines ? And, what's wrong with using sensible variable names ?
pandapatin wrote: Call sHexDecode(txtHex.Text)
oCP.Write(Encoding.ASCII.GetBytes(Me.TextBox1.Text)))))
Why not rewrite the function to return a string ? It looks like you don't really need the textbox ? Do you really need to specify 'call' ? I don't think so.
What was the exact problem again ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
now the code already working.but the location of the output is not the same as the input.let say the input=101000,the output would look like this"001010=...".its changes place from last place to 1st place.actually i set it to read pair by pair.If Mid(sData, iChar, 2) = "00" Then it doest read odd num input.
|
|
|
|
|
pandapatin wrote: doest read odd num input.
I'm suggesting you should fix that, so that the code doesn't break on bad input.
I guess you need to step through the debugger and work out what's going on. If the values are being flipped, then perhaps you need to flip the assignment to assign the values in reverse.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thx dude..its working now..
|
|
|
|
|
Hi, i want to change the width of the scrollbar programmatically. I found that using SystemParametersInfo API call, usingSPI_GETNONCLIENTMETRICS /SPI_SETNONCLIENTMETRICS , we can do that.
But i dont have the complete information.
Do you guys have some idea about that?
|
|
|
|
|
|
It would be great if you could provide me code or give me an idea on increasing the default scroll bar width because i dont have good knowledge on WinAPI stuffs.
|
|
|
|
|
Hi everyone,
I'm trying to upload an *.xml file to my server and this is the code I'm using. The problem I have is that I get a 403 error every time, even though my folder permissions are correct and my authentications are correct as well. Just wondering if I'm doing something wrong with my code.
If File.Exists("C:\Documents and Settings\Denis\Desktop\GetFileTest\test.xml") Then
Dim remoteUri As String = "http://www.site.com/folder/"
Dim fileName As String = "C:\Documents and Settings\Denis\Desktop\GetFileTest\test.xml"
' Create a new WebClient instance.
Dim myWebClient As New WebClient
myWebClient.Credentials = New NetworkCredential("username", "password", "http://www.site.com/")
Try
' The UploadFile() method uploads the current file to the Web resource-system folder.
myWebClient.UploadFile(remoteUri, fileName)
Label.Text = "Done!"
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
Label.Text = "No Go!"
End If
Thanks for any help
~D~
modified on Friday, February 22, 2008 11:33 AM
|
|
|
|
|
Darshon wrote: myWebClient.Credentials = New NetworkCredential("username", "password", "http://www.site.com/")
You're specifying the domain as a URI. What this parameter should contain in the domain of the credentials you type into the Username/Password/Domain box when it shows up, if you did this manually. The domain it wants is the Windows domain where the User account is stored, not a URI. For most public websites, the domain box is left blank. So, try it without the domain parameter.
myWebClient.Credentials = New NetworkCredential("username", "password")
|
|
|
|
|
Hi Dave,
Thanks for the explaination. I did try it without the domain but it still gave me the same 403 error. I'm quite puzzled, this should work. Could it be something wrong with my server? I can upload files through an ftp program, is there a way to upload a file through ftp within the 1.1 framework?
~D~
|
|
|
|
|
I have a query regarding remote SQL Server Connection in VB.Net . Let me exlain you the scenario. A company has two branches in two different cities. Let it be CityA and CityB. CityA holds the Server Machine on which a SQL Server is installed and running. CityB wants to connect to SQL Server running at CityA. But make sure that both of these use only internet to communicate. Moreover, SQL Server is not running on a web server or intranet scenario. Please help !!!
|
|
|
|
|
This has nothing to do with VB.NET, but everything to do with your companies network infrastructure. You never, Never, NEVER expose an SQL Server directly to the Internet. You'll have a smoking heap of a server in about a day when every little script-kiddie recognizes what it is.
You always put these servers behind as much security as possible. If you can't get your own T1 line between sites, you'll have to use the Internet and setup virtual private networking between sites. This will keep the data going between sites, including SQL Server traffic, secured and hidden from the prying eyes of the Internet.
Setting up the hardware and software for a VPN connection is way beyond the scope of these forums.
|
|
|
|
|
1. Disable firewall
2. Publish login detail
3. Everybody here will help you
|
|
|
|
|
Hi,
I am working on ASP application and I want to send a scheduled email by daily. Can any body help me to sort out the issue.
Thank
S.ABC
|
|
|
|
|
You have posted into the wrong forum, but to answer your question, you can't. You could add a task to your windows scheduler the executes daily that launches an asp page which in turn sets the email to you, or write a windows service and install in on your server.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
I often see postings in this forum, where it is stated "I am developing in VB6". Why are they still developing in VB6?
It seems to me that any new developments should now be done in VB2005/8 and if it is a new or replacement module/class for a legacy VB6 program, then still write it in VB.NET and make it COM visible and reference it from the VB6 app.
Am I missing something? Are my assumption wrong?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Steven J Jowett wrote: "I am developing in VB6". Why are they still developing in VB6?
Possibly they have no choice. I see often job postings where companies are asking for VB6 skills (I even got one yesterday). So until companies give it up people will still need to ask questions on forums.
|
|
|
|
|
Colin Angus Mackay wrote: companies are asking for VB6 skills
So the employers need to be educated in the benefits of ceasing development in vb6 and migrating to .NET
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Companies have large code-bases written in VB6. They see the short-term expense of rewriting that code in VB.NET and don't migrate because of it. Though, they also ignore the ever increasing costs of maintain legacy code too.
|
|
|
|
|
Dave Kreskowiak wrote: They see the short-term expense of rewriting that code in VB.NET and don't migrate because of it. Though, they also ignore the ever increasing costs of maintain legacy code too.
You would think the "drunken lemurs" ( errr, managers ) would look at the short term cost of porting to VB.NET be more cost effective than maintaining the VB6...
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Steven J Jowett wrote: So the employers need to be educated in the benefits of ceasing development in vb6 and migrating to .NET
Wish it is that simple.
Cost, risk, re-training, disruption to business, to name a few....
|
|
|
|
|
For how long should you flog a dead horse?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Until the shareholders revolt and lynch the CEO.
|
|
|
|
|
Until the guys who's paying for the system are convinced and willing to redo the system...
Look, we have a system, written in Delphi 5, each sub module is one exe, and there are hundreds of them, from A01 to G99, that are used by a few branches in different country, each having different business logic, and as such each branches are having the similar but not the same A01.exe-G99.exe, same for the database, enhancement is done by copy the exe and change from there, every queries are embedded in the form, and you must look at each form to look at the SQL statement, the way of passing variable is to make in-memory temp tables, then call SQL to retrieve the values from the temp tables, the database field are all user defined type for no apparent reason and benefit, date is stored as integer, money is stored as integer after mutiplied by 10000, rates are stored as integer after multiplied by 100, 10000 or 1000000 depends on the mood of the programmer, language support on a platform that doesn't support multi-languages, functions are duplicated all over the places...
Simply put, the style of the system was done in the fashion in the dBase era.
I would make a new system in a heartbeat, if I have the say. But until the people who's paying for the system are ready to remake that pile of doo-doo, the system needs to be maintained as it is.
Good thing I am not the one who's maintaining it....
|
|
|
|