473,473 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

for all the vb.net experts

This codes was from vb5 and im trying to replace/update it to vb.net, i
just need expert's feedback on this before i start changing stuff coz im
not that good im just a newbie!
Private Sub SSCommand2_Click()
Dim SourceChan As Integer
Dim DestinChan As Integer
Dim FileLen As Long

Dim SourceSP As Long
Dim NewSourceSP As Long
Dim SourceEP As Long
Dim DestinSP As Long
Dim NewDestinSP As Long
Dim DestinEP As Long
Dim SourceLen As Long
Dim DestinLen As Long

Dim FindChar As String
Dim CombinedFile As String
Dim Header As String

Dim LabelCount As Long
Dim LineCount As Long
Dim char As Byte
Dim CustomLBL As Boolean
Dim SigID As Integer
CustomLBL = False

msg = "The Source File will be Appended to the End of" _
& Chr(13) & Chr(10) & "the Current Job File, OK"
Style = vbYesNo + vbInformation + vbDefaultButton2
Title = "Append to Job File"
response = MsgBox(msg, Style, Title)
If response = vbYes Then
GoTo BeginAppend
Else
GoTo ExitAppend
End If

BeginAppend:

Screen.MousePointer = 11

'<>
'<> see if source file has a header (file to be appended)
'<>

SourceChan = FreeFile

Open FileName1 For Binary As SourceChan
SourceLen = LOF(SourceChan)
SourceFile = String(SourceLen, 0)
Get #SourceChan, , SourceFile
Close #SourceChan

SourceSP = 1
FindChar = "<eoh>"

If Left(SourceFile, 4) = "@fmt" Then
SourceSP = InStr(SourceFile, FindChar)
SourceSP = SourceSP + 6 ' <eoh> + crlf

' see if custom format
FindChar = ".sig"
SigID = InStr(SourceFile, FindChar)
If SigID > 0 Then
If Mid(SourceFile, SigID - 3, 1) = "5" Then
CustomLBL = True
SLBLLineCount = 5
Else
CustomLBL = False
SLBLLineCount = 4
End If
End If
End If

'<>
'<> no append allowed on a custom label format, new run only
'<>

If CustomLBL = True Then
msg = "The Source is a Custom Format, you can not " _
& Chr(13) & Chr(10) & "Append this type, use 'New Run' button, OK"
Style = vbOKOnly + vbInformation
Title = "Append to Job File"
response = MsgBox(msg, Style, Title)

GoTo ExitAppend
End If

If SourceSP > 1 Then
NewSourceSP = SourceSP + 1 ' first position after crlf
Header = Left(SourceFile, SourceSP)
Else
NewSourceSP = 1
Header = ""
End If
FindChar = vbLf
SourceSP = Len(SourceFile)

If Right(SourceFile, 1) <> FindChar Then

Do Until InStr(SourceSP, SourceFile, FindChar) > 0
SourceSP = SourceSP - 1
Loop

End If
SourceEP = SourceSP

DestinChan = FreeFile

Open FileName2 For Binary As DestinChan
DestinLen = LOF(DestinChan)
DestinFile = String$(DestinLen, 0)
Get #DestinChan, , DestinFile
Close #DestinChan
FindChar = vbLf
DestinSP = Len(DestinFile)

If Right(DestinFile, 1) <> FindChar Then

Do Until InStr(DestinSP, DestinFile, FindChar) > 0
DestinSP = DestinSP - 1
Loop

End If

DestinEP = DestinSP
CombinedFile = Left(DestinFile, DestinEP)
CombinedFile = CombinedFile + Mid(SourceFile, NewSourceSP, (SourceEP
- NewSourceSP))

Open FileName2 For Output As DestinChan
Print #DestinChan, CombinedFile
Close #DestinChan
char = Asc(vbLf)
LblCount = 0
LineCount = 0

LineCount = DxFileLineCount(FileName2, char)

LblCount = Int(LineCount / SLBLLineCount)
Label7.Caption = Str(LblCount)
Label7.Refresh

SourceFile = FileName1
DestinFile = SourceFilePath(3) + Format(Now, "MMM") + "\" +
File1.FileName

On Error GoTo DestNotFound
Open DestinFile For Input As #25
If LOF(25) > 0 Then
Close #25
GoTo AllreadyE
End If

DestNotFound:

On Error GoTo 0
FileCopy SourceFile, DestinFile
GoTo ContNoError

AllreadyE:

Screen.MousePointer = 0

On Error GoTo 0
msg = "The Archive Backup File Already Exists " _
+ Chr(13) + Chr(10) + "Replace?"
Style = vbYesNo + vbInformation + vbDefaultButton2
Title = "Archive Source File"
response = MsgBox(msg, Style, Title)

If response = vbYes Then
FileCopy SourceFile, DestinFile
End If

ContNoError:

Kill SourceFile

File1.Pattern = "*.xyz"
File1.Pattern = Text1.Text
DoEvents

msg = "New Bar Code Job File is Complete"
Style = vbOKOnly + vbInformation
Title = "New Run Appended"
response = MsgBox(msg, Style, Title)
SSCommand1.Enabled = False
SSCommand2.Enabled = False
SSCommand5.Enabled = False
SSCommand6.Enabled = False
Label1.Caption = ""
Label3.Caption = ""

ExitAppend:

Screen.MousePointer = 0
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
1 1172
Ryan Epinos wrote:
This codes was from vb5 and im trying to replace/update it to vb.net, i
just need expert's feedback on this before i start changing stuff coz im
not that good im just a newbie!
You may find this is a simpler transition than you might have expected.
Try it out, start typing.
If you want the entire thing rewritten for you, I get $75 per hour.

Tom
*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: ByteSize | last post by:
Dear All, Please, this is not meant to be offensive - but it is a challenge !!! I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete,...
28
MMcCarthy
by: MMcCarthy | last post by:
Policies below superceded by FAQ Post Course Work Questions and Answers. ADMIN
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.