473,762 Members | 8,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error : Value does not fall within the expected range VB.Net 2005

115 New Member
i'm using VB.Net 2005 application program.

i'm trying to convert VB6 code to VB.Net 2005. QSockB is DLL file.

this is the code i used for VB6. This is code i'm using to create socket, when program runs... and when i hit start button it calls Q_SendHeader function.

Expand|Select|Wrap|Line Numbers
  1. Form1_Load(.....................
  2.  
  3.  Q_KDSPort = &H8000&
  4.  Q_MyPort = Q_KDSPort + &H100&
  5.  Q_Address = ADDRESS_ANY
  6.  Q_CreateSocketPort
  7.  
Expand|Select|Wrap|Line Numbers
  1. Module QSockB
  2.  
  3.     Declare Function QSOCKNETINIT Lib "QSockB" () As Long
  4.  
  5.     Declare Function QSOCKOPENSOCKETEX Lib "QSockB" _
  6.           (ByRef hndSocket As Long, ByVal lngPort As Long, _
  7.           ByVal szIPAddress As String) As Long
  8.  
  9.     Declare Function QSOCKSENDMESSAGEEX Lib "QSockB" (ByVal hndSocket As Long, ByVal lngPort As Long, ByVal szIPAddress As String, ByRef szData As Any, ByVal lngDataLength As Long) As Long
  10.  
  11.  
  12.     Public Const ADDRESS_ANY As String = "AnyAddress"
  13.  
  14.     Structure KDS_HEADER
  15.         Dim lngFunction As Long
  16.         Dim lngSubFunction As Long
  17.     End Structure
  18.  
  19.  
  20.     Structure KDS_TRANSACTION_HEADER
  21.         Dim lngTransactionNumber As Long
  22.         Dim lngTerminalNumber As Long
  23.         Dim lngDestination As Long
  24.         Dim lngSystemTime As SystemTime
  25.         Dim lngTableNumber As Long
  26.         Dim lngServerId As Long
  27.         Dim lngCourse As Long
  28.         Dim lngReserved1 As Long
  29.         Dim lngReserved2 As Long
  30.         Dim lngReserved3 As Long
  31.         Dim lngReserved4 As Long
  32.         Dim lngReserved5 As Long
  33.         Dim lngReserved6 As Long
  34.         Dim lngReserved7 As Long
  35.         Dim lngReserved8 As Long
  36.         <VBFixedString(31)> Dim lpszServerName As String
  37.         <VBFixedString(31)> Dim lpszCustomerName As String
  38.         Dim lngFlags As Long
  39.     End Structure
  40.  
  41.     Structure HEADER_MSG
  42.         Dim Hdr As KDS_HEADER
  43.         Dim Data As KDS_TRANSACTION_HEADER
  44.     End Structure
  45.  
  46.     Public Function Q_CreateSocketPort()
  47.         Dim ReturnCode As Long
  48.  
  49.            Q_CreateSocketPort = False
  50.  
  51.         ReturnCode = QSOCKNETINIT
  52.  
  53.         If ReturnCode = SOCK_ERROR_NONE Then
  54.              ReturnCode = QSOCKOPENSOCKETEX(Q_Socket, Q_MyPort, Q_Address)
  55.              If ReturnCode = SOCK_ERROR_NONE Then
  56.                  Q_Connected = True
  57.                  Q_CreateSocketPort = True
  58.              End If
  59.         End If
  60.     End Function
  61.  
  62.  
  63.     Public Function Q_SendHeader(ByVal TransactionNumber, ByVal Terminal, ByVal VideoChannel, ByVal UniqueTableID, ByVal ServerID, ByVal Course As Long, ByVal ServerName, ByVal HoldName As String, ByVal TimeHeld As Date) As Long
  64.         Dim Header As HEADER_MSG
  65.  
  66.   With Header.Hdr
  67.          .lngFunction = RDS_FUNCTION_POS_VB
  68.          .lngSubFunction = RDS_MESSAGE_HEADER
  69.        End With
  70.  
  71.        With Header.Data
  72.          .lngTransactionNumber = TransactionNumber
  73.          .lngTerminalNumber = Terminal 'must be non-zero
  74.          .lngDestination = VideoChannel 'as defined in the KDS (Destination ID's)
  75.          .lngTableNumber = UniqueTableID
  76.          .lngServerId = ServerID
  77.          .lngCourse = Course
  78.          .lngReserved1 = 0
  79.          .lngReserved2 = 0
  80.          .lngReserved3 = 0
  81.          .lngReserved4 = 0
  82.          .lngReserved5 = 0
  83.          .lngReserved6 = 0
  84.          .lngReserved7 = 0
  85.          .lngReserved8 = 0
  86.  
  87.          ' We must Add a Chr(0) to the end of each string to NULL terminate
  88.          If Len(Trim(ServerName)) > 0 Then
  89.            .lpszServerName = Trim(ServerName) + Chr(0)
  90.          Else
  91.             .lpszServerName = Chr(0)
  92.          End If
  93.  
  94.          If Len(Trim(HoldName)) > 0 Then
  95.  .lpszCustomerName = Left(Trim(HoldName), 30) + Chr(0)        
  96.          Else
  97.             .lpszCustomerName = Chr(0)
  98.          End If
  99.  
  100.      End With
  101.  
  102.       Q_SendHeader = QSOCKSENDMESSAGEEX(Q_Socket, Q_KDSPort, Q_Address, Header, Len(Header))
  103.     End Function
  104.  
  105. End Module
  106.  


this is the code i'm using for VB.Net 2005.

This is code i'm using to create socket, when program runs... and when i hit button start, its calling Q_SendHeader function.

Expand|Select|Wrap|Line Numbers
  1. Public objQ As clsQSockB
  2.  
  3. Private Sub Form1_Load(……………………………………
  4.     objQ = New clsQSockB
  5.     objQ.Q_KDSPort = &H8000&
  6.     objQ.Q_MyPort = objQ.Q_KDSPort + &H100&
  7.     objQ.Q_Address = clsQSockB.ADDRESS_ANY
  8.     objQ.Q_CreateSocketPort()
  9. End Sub
  10.  
  11. Private Sub btnStart_Click(………………………………
  12.         objQ.Q_SendHeader(100, 33, 1, 100, 3, 1, "Server", 100, Now.Date)
  13. End Sub
  14.  
Expand|Select|Wrap|Line Numbers
  1. Public Class clsQSockB
  2.  
  3.     Declare Function QSOCKNETINIT Lib "QSockB" () As Int32
  4.  
  5.     Declare Function QSOCKOPENSOCKETEX Lib "QSockB" _
  6.           (ByRef hndSocket As Int32, ByVal lngPort As Int32, _
  7.           ByVal szIPAddress As String) As Int32
  8.  
  9.     Declare Function QSOCKSENDMESSAGEEX Lib "QSockB" (ByVal hndSocket As Int32, ByVal lngPort As Int32, ByVal szIPAddress As String, ByVal szData As Object, ByVal lngDataLength As Int32) As Int32
  10.  
  11.     Public Q_Socket As Int32
  12.     Public Q_MyPort As Int32
  13.     Public Q_KDSPort As Int32
  14.     Public Q_Address As String
  15.  
  16.     Public Const ADDRESS_ANY As String = "AnyAddress"
  17.  
  18.     Structure KDS_HEADER
  19.         Dim lngFunction As Int32
  20.         Dim lngSubFunction As Int32
  21.     End Structure
  22.  
  23.     Structure KDS_TRANSACTION_HEADER
  24.         Dim lngTransactionNumber As Int32
  25.         Dim lngTerminalNumber As Int32
  26.         Dim lngDestination As Int32
  27.         Dim lngSystemTime As SystemTime
  28.         Dim lngTableNumber As Int32
  29.         Dim lngServerId As Int32
  30.         Dim lngCourse As Int32
  31.         Dim lngReserved1 As Int32
  32.         Dim lngReserved2 As Int32
  33.         Dim lngReserved3 As Int32
  34.         Dim lngReserved4 As Int32
  35.         Dim lngReserved5 As Int32
  36.         Dim lngReserved6 As Int32
  37.         Dim lngReserved7 As Int32
  38.         Dim lngReserved8 As Int32
  39.         <VBFixedString(31)> Dim lpszServerName As String
  40.         <VBFixedString(31)> Dim lpszCustomerName As String
  41.         Dim lngFlags As Int32
  42.     End Structure
  43.  
  44.     Structure HEADER_MSG
  45.         Dim Hdr As KDS_HEADER
  46.         Dim Data As KDS_TRANSACTION_HEADER
  47.     End Structure
  48.  
  49.     Public Function Q_CreateSocketPort() As Boolean
  50.         Try
  51.             Dim ReturnCode As Long
  52.             'Attempt to initial QSockB.DLL
  53.             ReturnCode = QSOCKNETINIT()
  54.             If ReturnCode = SOCK_ERROR_NONE Then
  55.                 ReturnCode = QSOCKOPENSOCKETEX(Q_Socket, Q_MyPort, Q_Address)
  56.                 If ReturnCode = SOCK_ERROR_NONE Then
  57.                     Q_Connected = True
  58.                     Return True
  59.                 End If
  60.             End If
  61.         Catch ex As Exception
  62.             Return False
  63.         End Try
  64.     End Function
  65.  
  66.  
  67.     Public Function Q_SendHeader(ByVal TransactionNumber As Object, ByVal Terminal As Object, ByVal VideoChannel As Object, ByVal UniqueTableID As Object, ByVal ServerID As Object, ByVal Course As Int32, ByVal ServerName As Object, ByVal HoldName As String, ByVal TimeHeld As Date) As Int32
  68.         Try
  69.             Dim Header As HEADER_MSG
  70.  
  71.             With Header.Hdr
  72.                 .lngFunction = RDS_FUNCTION_POS_VB
  73.                 .lngSubFunction = RDS_MESSAGE_HEADER
  74.             End With
  75.  
  76.             With Header.Data
  77.                 .lngTransactionNumber = TransactionNumber
  78.                 .lngTerminalNumber = Terminal 'must be non-zero
  79.                 .lngDestination = VideoChannel 'as defined in the KDS (Destination ID's)
  80.                 .lngTableNumber = UniqueTableID
  81.                 .lngServerId = ServerID
  82.                 .lngCourse = Course
  83.                 .lngReserved1 = 0
  84.                 .lngReserved2 = 0
  85.                 .lngReserved3 = 0
  86.                 .lngReserved4 = 0
  87.                 .lngReserved5 = 0
  88.                 .lngReserved6 = 0
  89.                 .lngReserved7 = 0
  90.                 .lngReserved8 = 0
  91.  
  92.                 ' We must Add a Chr(0) to the end of each string to NULL terminate
  93.                 If Len(Trim(ServerName)) > 0 Then
  94.                     .lpszServerName = Trim(ServerName) + Chr(0)
  95.                 Else
  96.                     .lpszServerName = Chr(0)
  97.                 End If
  98.  
  99.                 If Len(Trim(HoldName)) > 0 Then
  100.                     .lpszCustomerName = Left(Trim(HoldName), 30) + Chr(0)
  101.                 Else
  102.                     .lpszCustomerName = Chr(0)
  103.                 End If
  104.  
  105.             End With
  106.  
  107.             Return QSOCKSENDMESSAGEEX(Q_Socket, Q_KDSPort, Q_Address, Header, Len(Header))
  108.  
  109.         Catch ex As Exception
  110.             Return -1
  111.         End Try
  112.     End Function
  113. End Class
  114.  

Creating Socket works fine. but when i call Q_SendHeader, getting error.

Error i'm getting is
Value does not fall within the expected range.
when it reach this line in Q_SendHeader, its getting error...
Return QSOCKSENDMESSAG EEX(Q_Socket, Q_KDSPort, Q_Address, Header, Len(Header))
This works fine in VB6... but Q_SendHeader is not working in VB.Net 2005.

anything wrong with the code... if you have any idea what's wrong with the code, please help me... please.....

Thanks in advance.
Apr 30 '09 #1
0 2118

Sign in to post your reply or Sign up for a free account.

Similar topics

67
4278
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++. That usually serves to divert the discussion from the technical subject to a discussion of the...
13
9649
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
9
2932
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval ("document.forms."+rowString+".value")) == true ) { //this alert works if the value is a letter,i.e,"a" alert("You have entered an non-numeric value.\nEnter a number in the appropriate box.");
17
27284
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my machine (NT4, Access 2k), however as soon as I attempt to create anything on another machine (NT4, Access 2k) which most users will be working from, I receive an automation error. The problem line with the code is:
4
11811
by: javatopia | last post by:
Hello, I am trying to show a Crystal Reports 10 Enterprise report in an ASP.NET page (C#). I can run the report via the admin console just fine. When I try to show the report, after setting up its parameters, I get: "Value does not fall within the expected range." How are people interacting with the Crystal Report viewer to set the parameters on a report? I haven't found any useful documentation at
0
23509
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub) 5: Procedure call or argument is not valid. 6: Overflow. 7: Out of memory.
2
5122
by: Suresh | last post by:
Hello All, Can anyone help me with this error? I have developed an application using VB Express Edition. The backend being Oracle XE. The application is been published on the server, installation in the clients are fine. When I start up the application, in this case, a login screen. It throws up a error saying "value does not fall within expected range". This is happening only on Win2000 machines. On XP it works fine. Installed .NET...
1
1710
by: Chubbly Geezer | last post by:
I have an application that has previously been working correctly. However, having made some code changes today, the app still publishes correctly but when I try to run it I get the following error:- "Application cannot be started. Contact the application vendor." When I check the error details I get the following which may mean something to someone:- -----
22
27073
by: subramanian100in | last post by:
Consider the following program #include <limits.h> #include <stddef.h> int main(void) { size_t size; size_t bytes = sizeof(size_t);
0
9378
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9927
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9812
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.