| |

VerySource

 Forgot password?
 Register
Search
View: 2412|Reply: 13

VB programmers, let's talk about reusing code.

[Copy link]

1

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-17 13:00:01
| Show all posts |Read mode
Many other programming systems use inheritance to achieve polymorphism, and Visual Basic does not provide inheritance to provide polymorphism. Who can explain the code reuse method in VB?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-22 22:15:01
| Show all posts
Strongly concerned. There has always been the same question.
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-4-23 21:15:01
| Show all posts
Just enter any qq number in the text box, and then open the dialog box with this QQ,
I saw a lot of similar small software on the Internet, I think it should be very easy to use vb, but I do it
It won't be, huh, please advise
code show as below:


Private Sub Command1_Click ()
Dim num As Integer
p = Text1.Text
Shell ("explorer.exe tencent: // message /? Uin = p")
End Sub


Have you seen it? I want to use the variable p to store the QQ number entered in text1.text
Then combined with the base URL
But explorer.exe tencent: // message /? Uin = p won't open
Please advise on what to do.
Reply

Use magic Report

0

Threads

45

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-6-5 10:30:01
| Show all posts
Just change to VB.NET. ^_^
Reply

Use magic Report

0

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-4 19:30:01
| Show all posts
Shell ("explorer.exe tencent://message/?uin="+p)
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-7-10 16:30:01
| Show all posts
How can the p variable be placed in the "" sign? gosh. Upstairs right.
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-17 09:45:01
| Show all posts
Come in for class
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 Korea, Republic of

Post time: 2020-7-18 18:00:02
| Show all posts
Polymorphic?
I once saw that it can be implemented with an interface in MSDN
Never used it. . .
Reply

Use magic Report

1

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-8-3 12:30:01
| Show all posts
tips: Does the Visual Basic class support inheritance?
   
  The most ridiculous thing about VB is its object-oriented characteristics. In fact, VB is an object-based development tool. In VB
  The established class supports inheritance. The following is an example:
   
  First create a new project, then add a new class module (Class Module), the class name is set to BaseClass.
  Then add the following code to BaseClass:
   
  Public Sub BaseSub()'Virtual characteristics, BaseSub is implemented in subclasses
   
  End Sub
   
  Then add two class modules, set the class names to ImpClass and ImpClass2 respectively, and write in the code window of the class:
  Implements BaseClass'Inheritance characteristics
  The above line of code shows that the ImpClass and ImpClass2 implement the BaseClass.
  Add the following code in the ImpClass window:
  Private Sub BaseClass_BaseSub()'Implement the BaseSub method in the base class
  MsgBox "Hello. This is Imp. inherited from BaseClass"
  End Sub
   
  Add the following code in ImpClass2:
  Private Sub BaseClass_BaseSub()
  MsgBox "Hello. This is Imp2. inherited from BaseClass"
  End Sub
   
  After completing the above class code, open Form1, add a CommandButton on it, in the Click event of the button
  Write the following code:
   
  Dim xImp As New ImpClass
  Dim xIMp2 As New ImpClass2
  Dim xBase As BaseClass
   
  Set xBase = xImp'polymorphic characteristics
  xBase.BaseSub
  Set xBase = xIMp2
  xBase.BaseSub
  Set xBase = Nothing
   
  Set xImp = Nothing
  Set xIMp2 = Nothing
   
   
  Run the program, click CommandButton, the program will pop up message boxes successively, displayed in ImpClass and ImpClass2
  The set message.
  From the above code, you can see how object-oriented features are implemented in VB: inheritance, virtualization, and polymorphism. Just the same
  Unlike Java, C++, Object Pascal, VB hides many implementation details.
   
   
  Question: How to block the close button X in the form?
  Answer: You can use the API function to gray out the Close item in the form menu, because the menu is associated with the close button, so close
  The button will also be unavailable. The specific code is as follows:
   
  Option Explicit
   
  Private Declare Function GetSystemMenu Lib "user32" _
  (ByVal hwnd As Long, ByVal bRevert As Long) As Long
  Private Declare Function RemoveMenu Lib "user32" _
  (ByVal hMenu As Long, ByVal nPosition As Long, _
  ByVal wFlags As Long) As Long
  Private Declare Function EnableMenuItem Lib "user32" _
  (ByVal hMenu As Long, ByVal wIDEnableItem As Long, _
  ByVal wEnable As Long) As Long
   
  Const SC_CLOSE =&HF060
   
  Private Sub Form_Load()
  Dim hMenu As Long
   
  hMenu = GetSystemMenu(Me.hwnd, 0)
  RemoveMenu hMenu,&HF060,&H200&
  Debug.Print EnableMenuItem(hMenu, SC_CLOSE, 1)
  End Sub
Reply

Use magic Report

1

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-8-3 13:00:01
| Show all posts
VB inheritance is not too easy to understand
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list