What they were trying to do is extract the high order byte from the number.
"josh via DotNetMonster.com" wrote:
> here is a sample of what I want to do. Sorry so long. this is the code in vb.NET.
>
> Option Strict Off
> Option Explicit On
>
> Friend Class Form1
> Inherits System.Windows.Forms.Form
>
> #Region " Windows Form Designer generated code "
>
> Public Sub New()
> MyBase.New()
>
> 'This call is required by the Windows Form Designer.
> InitializeComponent()
>
> 'Add any initialization after the InitializeComponent() call
>
> End Sub
>
> 'Form overrides dispose to clean up the component list.
> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> If disposing Then
> If Not (components Is Nothing) Then
> components.Dispose()
> End If
> End If
> MyBase.Dispose(disposing)
> End Sub
>
> 'Required by the Windows Form Designer
> Private components As System.ComponentModel.IContainer
>
> 'NOTE: The following procedure is required by the Windows Form Designer
> 'It can be modified using the Windows Form Designer.
> 'Do not modify it using the code editor.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
> '
> 'Form1
> '
> Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
> Me.ClientSize = New System.Drawing.Size(292, 266)
> Me.Name = "Form1"
> Me.Text = "Form1"
>
> End Sub
>
> #End Region
> '============================================================
> Const SECS_PER_DAY As Integer = 86400
> Const SECS_PER_MINUTE As Integer = 60&
> Const SECS_PER_HOUR As Integer = 3600&
> Const BASE_YEAR As Integer = 1970&
>
> Public PublicInt1 As String
> Public PublicInt2 As String
>
> Dim ChangedSeconds As Integer
> Dim seconds As Integer
> Dim daycnt As Integer
> Dim fltbin As String
> Dim num_days(11) As Object
> Dim nib As String
>
> Private Declare Sub MoveMemory Lib "KERNEL32" Alias _
> "RtlMoveMemory" (ByRef hpvDest As Object, _
> ByRef hpvSource As Object, _
> ByVal cbCopy As Integer)
>
> Private Sub Form1_Load(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
>
> PublicInt1 = "01/25/2005"
> PublicInt2 = "14:00:00"
>
> daycnt = 365 * (Mid(PublicInt1, 7, 4) - BASE_YEAR)
> daycnt = daycnt + (Mid(PublicInt1, 7, 4) - BASE_YEAR + 1) \ 4
> daycnt = daycnt + num_days(Mid(PublicInt1, 1, 2) - 1)
> daycnt = daycnt + (Mid(PublicInt1, 4, 2) - 1)
>
> If ((Mid(PublicInt1, 7, 4) Mod 4) = 0) And _
> (Mid(PublicInt1, 1, 2) > 2) Then
>
> daycnt = daycnt + 1
> End If
>
> seconds = daycnt * SECS_PER_DAY
> seconds = seconds + Mid(PublicInt2, 1, 2) * SECS_PER_HOUR
> seconds = seconds + Mid(PublicInt2, 4, 2) * SECS_PER_MINUTE
> seconds = seconds + Mid(PublicInt2, 7, 2)
>
> ChangedSeconds = seconds
>
> fltbin = Space(4)
> Call MoveMemory(fltbin, ChangedSeconds, 4)
> nib = Asc(Mid(fltbin, 4, 1))
> End Sub
>
> End Class
>
> Now, in my program in vb6, i get fltbin = "?P?A" and nib = 65, this always gives me the correct output.
>
> In vb.NET, i get fltbin = "1631788" and this gives me incorrect output.
>
> PublicInt1 = the date that is entered by the user, and
> PublicInt2 = the time that is entered by the user.
> daycnt = # of days since 1970 = 17808
> seconds = # of sec's since 1970 = 1106661600
>
> We just are trying to understand this movememory thing because we didn't write the program, but we are responsable for converting it to vb.NET.
>
> --
> Message posted via
http://www.dotnetmonster.com