[Wish] function With

sioconcept

Active Member
Licensed User
Longtime User
In VB6, we have the method "With"; to win time.
It's call an object and apply more options :

With ListView1
.TwoLinesLayout.ItemHeight = 100
.TwoLinesLayout.Label.TextSize = 20
.TwoLinesLayout.SecondLabel.TextColor = Colors.Gray
.TwoLinesLayout.SecondLabel.Top = 40
End With

Please, add it, it's so quickly :sign0060:
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
And itd be quite easy too
Anytime the with command is used it just pushes the text after it on to a stack
End with removes the last added text off the stack
Any not fully qualified reference just has the last stack item prepended
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Never really used this in in VB. Not much more than just a time saver...assuming the IDE gives a dropdown when you type the . within it. Now to know you are inside it the End would need typed...there is a suggestion somewhere by me or someone else about auto Ending blocks that would help too- [Type Sub YourSubname then Press Enter and End Sub is typed/completed and cursor is placed inside the block]. I usually use the clipboard for this type of stuff and copy the object name then paste on multiple lines. Now if it worked like C# Using it may add some value...even if just a part of it so it is more than just a shorthand coding addition.
 

sioconcept

Active Member
Licensed User
Longtime User
Of course,

You can have a better code, more clean and easy

B4X:
With List_Planning.TwoLinesAndBitmap
   .ImageView.Width = 96
   .ImageView.Height = 96
   .ImageView.Left = 12
   .ImageView.Top = 10
   .Label.Left = 120
   .Label.Height = 50
   .SecondLabel.Left = 120
   .SecondLabel.Top = 40
   .SecondLabel.Height = 76
   .ItemHeight = 116
   .Label.Gravity = Gravity.CENTER_VERTICAL
   .SecondLabel.Gravity = Gravity.CENTER_VERTICAL
   .Label.TextColor = Colors.Black
   .SecondLabel.TextColor = Colors.DarkGray
   .Label.TextSize = 18
   .Label.Typeface = Typeface.DEFAULT_BOLD
   .SecondLabel.TextSize = 14
End With

VERSUS
B4X:
List_Planning.TwoLinesAndBitmap.ImageView.Width = 96
List_Planning.TwoLinesAndBitmap.ImageView.Height = 96
List_Planning.TwoLinesAndBitmap.ImageView.Left = 12
List_Planning.TwoLinesAndBitmap.ImageView.Top = 10
List_Planning.TwoLinesAndBitmap.Label.Left = 120
List_Planning.TwoLinesAndBitmap.Label.Height = 50
List_Planning.TwoLinesAndBitmap.SecondLabel.Left = 120
List_Planning.TwoLinesAndBitmap.SecondLabel.Top = 40
List_Planning.TwoLinesAndBitmap.SecondLabel.Height = 76
List_Planning.TwoLinesAndBitmap.ItemHeight = 116
List_Planning.TwoLinesAndBitmap.Label.Gravity = Gravity.CENTER_VERTICAL
List_Planning.TwoLinesAndBitmap.SecondLabel.Gravity = Gravity.CENTER_VERTICAL
List_Planning.TwoLinesAndBitmap.Label.TextColor = Colors.Black
List_Planning.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.DarkGray
List_Planning.TwoLinesAndBitmap.Label.TextSize = 18
List_Planning.TwoLinesAndBitmap.Label.Typeface = Typeface.DEFAULT_BOLD

:sign0098:
 
Top