Multiple references pointing to the same string?

miroxlav

Is the following simplification possible in the VB.NET?

Example: text variable pointing to another string:

Class Form1
    Sub New()
        Dim text As (what_type?) = AddressOf TextBox1.Text  'simplification
        If text = "foo" Then text = "bar"  'actually accessing TextBox1.Text
    End Sub
End Class

I think it is not possible, but I can be wrong.

Tim Schmelter

VB.NET doesn't have pointers. You can use properties:

Public Property Text As String
    Get
        Return TextBox1.Text
    End Get
    Set(value As String)
        TextBox1.Text = value
    End Set
End Property

You can use properties as layer to not expose the control itself but only relevant informations:

If Text = "foo" Then Text = "bar"  

On this way you could even change the control(f.e. to Label) without breaking code.

Another approach is using a lambda expression:

Dim setText = Sub(str As String) TextBox1.Text = str
setText("test")
Dim getText = Function() TextBox1.Text
Dim text As String = getText()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Multiple references pointing to the same string?

From Dev

=== returns false in Nashorn when both references should be pointing to the same object

From Dev

Pointing a multiple subdomains to same heroku application

From Java

Is it efficient to create multiple keys pointing to the same object?

From Dev

Single or Multiple Repositories pointing to same model

From Dev

Java - multiple hashmaps pointing to the same key

From Dev

Single or Multiple Repositories pointing to same model

From Dev

Multiple @ManyToOne fields pointing to same entity in JPA / Hibernate

From Dev

how can I configure yesod with multiple routes pointing to the same entity?

From Dev

Best practice in pointing multiple urls to same method in Laravel 4

From Dev

Python dictionary with multiple keys pointing to same list in memory efficient way

From Dev

Multiple keys pointing/refering to same Object in values in HashMap

From Dev

SQL Multiple foreign keys pointing to same primary key

From Dev

Mapping an entity with multiple references to the same type

From Dev

ServiceStack OrmLite multiple references of same type load

From Dev

Multiple Smart Pointer References to Same Object

From Dev

Microdata itemref - multiple references to the same item

From Dev

Destroying multiple references to the same object in Java

From Dev

multiple key vault references in same ARM template

From Dev

Variables Pointing To The Same Function

From Dev

Merge Javascript Objects and All References Pointing at Them

From Dev

EF 6 SaveChanges with multiple references to same (changed) object

From Dev

MS Word 365 - Multiple footnote references same word

From Dev

Prevent multiple foreign key references to same row in primary table

From Dev

Reference equality in Matlab struct. Can a struct have multiple field names pointing to the same object?

From Dev

Are two File pointing to the same file?

From Dev

Multiples menus pointing to the same article

From Dev

Router cakephp pointing to same action

From Dev

Are two File pointing to the same file?

Related Related

  1. 1

    Multiple references pointing to the same string?

  2. 2

    === returns false in Nashorn when both references should be pointing to the same object

  3. 3

    Pointing a multiple subdomains to same heroku application

  4. 4

    Is it efficient to create multiple keys pointing to the same object?

  5. 5

    Single or Multiple Repositories pointing to same model

  6. 6

    Java - multiple hashmaps pointing to the same key

  7. 7

    Single or Multiple Repositories pointing to same model

  8. 8

    Multiple @ManyToOne fields pointing to same entity in JPA / Hibernate

  9. 9

    how can I configure yesod with multiple routes pointing to the same entity?

  10. 10

    Best practice in pointing multiple urls to same method in Laravel 4

  11. 11

    Python dictionary with multiple keys pointing to same list in memory efficient way

  12. 12

    Multiple keys pointing/refering to same Object in values in HashMap

  13. 13

    SQL Multiple foreign keys pointing to same primary key

  14. 14

    Mapping an entity with multiple references to the same type

  15. 15

    ServiceStack OrmLite multiple references of same type load

  16. 16

    Multiple Smart Pointer References to Same Object

  17. 17

    Microdata itemref - multiple references to the same item

  18. 18

    Destroying multiple references to the same object in Java

  19. 19

    multiple key vault references in same ARM template

  20. 20

    Variables Pointing To The Same Function

  21. 21

    Merge Javascript Objects and All References Pointing at Them

  22. 22

    EF 6 SaveChanges with multiple references to same (changed) object

  23. 23

    MS Word 365 - Multiple footnote references same word

  24. 24

    Prevent multiple foreign key references to same row in primary table

  25. 25

    Reference equality in Matlab struct. Can a struct have multiple field names pointing to the same object?

  26. 26

    Are two File pointing to the same file?

  27. 27

    Multiples menus pointing to the same article

  28. 28

    Router cakephp pointing to same action

  29. 29

    Are two File pointing to the same file?

HotTag

Archive