473,467 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

class libary

43 New Member
Here is what I want it to do:
1: My form uses my class library dll to use a command called moveobject
2: My form sends button1 to the byval
3: The button on the form is moving

Here is what it does right now:
1: My form uses my class library dll to use a command called moveobject
2: My form sends button1 to the byval
3: Returning an error

I want to use the objects in the designer in the class library like this (GM is the name of my class library):

This is the form:

Expand|Select|Wrap|Line Numbers
  1.     Dim GMF As GM.functions
  2.     Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  3.         GMF.Move_fixed(Me.Button1, "1", 10)
  4.     End Sub
This is the class library:

Expand|Select|Wrap|Line Numbers
  1. Public Class functions
  2.     Dim way2
  3.     Dim obh As Object
  4.     Dim sp
  5.     Public Function Move_fixed(ByVal objectname As Object, ByVal way As String, ByVal speed As String)
  6.         way2 = way
  7.         obh = objectname
  8.         timer(speed)
  9.     End Function
  10.     Dim tt
  11.     Public Function timer(ByVal time As String) _
  12.     As String
  13.         tt = 100
  14.         sp = time
  15.         InitializeComponent()
  16.     End Function
  17.     Private Sub InitializeComponent()
  18.         Me.Timer1 = New System.Windows.Forms.Timer
  19.         'Timer1
  20.         '
  21.         Me.Timer1.Interval = tt
  22.         '
  23.         'Form1
  24.         Timer1.Enabled = True
  25.     End Sub
  26.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  27.         If way2 = "1" Then
  28.             With obh
  29.                 .Left = .Left + sp
  30.                 .top = .top + sp
  31.             End With
  32.         End If
  33.         If way2 = "2" Then
  34.             With obh
  35.                 .top = .top + sp
  36.             End With
  37.         End If
  38.         If way2 = "3" Then
  39.             With obh
  40.                 .Left = .Left - sp
  41.                 .top = .top + sp
  42.             End With
  43.         End If
  44.         If way2 = "4" Then
  45.             With obh
  46.  .Left = .Left + sp
  47.             End With
  48.         End If
  49.         If way2 = "5" Then
  50.             Timer1.Enabled = False
  51.             Timer1.Stop()
  52.         End If
  53.         If way2 = "6" Then
  54.             With obh
  55.                 .Left = .Left - sp
  56.             End With
  57.         End If
  58.         If way2 = "7" Then
  59.             With obh
  60.                 .Left = .Left - sp
  61.                 .top = .top - sp
  62.             End With
  63.         End If
  64.         If way2 = "8" Then
  65.             With obh
  66.                 .top = .top - sp
  67.             End With
  68.         End If
  69.         If way2 = "9" Then
  70.             With obh
  71.                 .Left = .Left + sp
  72.                 .top = .top - sp
  73.             End With
  74.         End If
  75.         Timer1.Enabled = True
  76.     End Sub
  77.     Friend WithEvents Timer1 As System.Windows.Forms.Timer
  78. End Class
Oct 28 '07 #1
7 1140
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

You are wanting to Pass the Form Control to class module, in that case you should not pass with "ByVal".
Remove ByVal for the Object and check..

REgards
Veena
Oct 28 '07 #2
patr0805
43 New Member
Its still not work because when I remove byval it returns.

I have VB.NET
Oct 28 '07 #3
cugone
20 New Member
Try passing the form by reference (ByRef)
Oct 29 '07 #4
Killer42
8,435 Recognized Expert Expert
Try passing the form by reference (ByRef)
Yes, I think they changed things. In VB6, ByRef was the default, so you only ever had to specify when you wanted to pass by value. In later versions, I believe ByVal is now the default, so if you want to pass a reference you need to say so.
Oct 29 '07 #5
Killer42
8,435 Recognized Expert Expert
Its still not work because when I remove byval it returns.
Huh?! It returns what?
Oct 29 '07 #6
Killer42
8,435 Recognized Expert Expert
On a slightly more positive note, I would recommend changing that big long stream of If way2 = tests. A Select Case would be the ideal, or you could just convert all but the first into ElseIf statements. Either way, it would make the code much easier to maintain.

At present, to be certain of what will happen at any point, you have to read carefully through all the prior ones, to ensure that the value of way2 can't change. Either of the two suggested alternatives would make the options all mutually exclusive, removing this requirement. This would have the added advantage of executing (very slightly) faster, since it would stop checking the rest of the conditions once it hit the True one.
Oct 29 '07 #7
patr0805
43 New Member
Hi the code is working 100% when I copy it directly inside the code in the form application, but it dont work in a class library that is the problem and yes Byval is now the default.

This is what I want it to do:
form with a button>uses class library>button is moving
Oct 29 '07 #8

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

Similar topics

4
by: C-Sharper or C-Hasher, one of the two | last post by:
Hi, I have a C# class libary (Class1) which is inherited by another class in a Windows Forms app. I want this other class to implement some, but not all of the features of the base class. How...
1
by: Roger Gordon | last post by:
I have the VB.NET Standard Edition. I'm taking a VB.NET class in school. Last night we tried to create a class libary and there was no option to do this in the Standard Edition. Our instructor...
1
by: Ron | last post by:
Hello, I need to create/instantiate a global class library project so that 2 EXE's can write to the same class library form in the same instance of the class libary. I am thinking something...
1
by: Tom Edelbrok | last post by:
I am creating a class libary of VB.Net utilities that will be built into a DLL. This DLL can be used by our development VB.NET programs when they want to call standard in-house utilities. I...
4
by: David McCallum | last post by:
First excuse my ignorance, but I'm completely new to VS2005 development I've created a new project and want to add an already written class stored elsewhere on the computer to the project. ...
3
by: Rich | last post by:
I put together a simple test class libary (VB2005) with one class and one function that takes an integer argument and adds 10 the argument and returns that number. Then I created a simple VB2005...
7
by: Peter Bradley | last post by:
OK. A bit behind the times, I know; but we're just moving over to .NET 2.0. How on earth do you manage configuration settings in a class library in .NET 2.0? In version 1.1, we used a handy class...
3
by: Jacob | last post by:
Hi! Where do i find .NET class libary in Visual studio? I mean if you would like to browse through the classes and members. Or if you want to search fr specific classes or members. Thanks in...
4
by: vedrandekovic | last post by:
Hello, Does anybody have any idea how can I embed my modules to libary.zip and use it from my application.For example if user write this code in my TextEntry ( or something like that, textentry...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
1
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...
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: 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...
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.