First test project in Gambas

Post

Posted
Rating:
#1 (In Topic #1200)
Trainee
Hi,
I am trying to do my first test project in Gambas after maybe 12 years not looking at VB..  This would a basic checker tool to assist me writing titles & keywords for my amazon listings and to calculate fee and taxes etc. I am facing some problems or maybe I don't understand to work with it yet. Some help would be appreciated to guide me solve the riddles:

When I close the application / form it clears the text from clipboard (in case I copy something from TextBox).. how can I fix it?

And below code to validate a product title is reading hyphen (-) as invalid character from TextBox input (typed or pasted).. though the character '-' is included in the pattern.. idk why?

Code (gambas)

  1. .....
  2.   For i = 1 To Len(TextBox2.Text)
  3.     If Mid(TextBox2.text, i, 1) Not Like "[A-Z, a-z, 0-9, ',', '.', '-', ' ', '/']" Then
  4.       ErrorString = ErrorString & Mid(TextBox2.Text, i, 1)
  5.       PatMatch = False
  6.     Endif
  7.   Next
  8.  
  9.   If PatMatch = False Then
  10.     TextBox1.Text = Trim(ErrorString)
  11.     TextBox1.Foreground = Color.DarkRed
  12.   Else
  13.     TextBox1.Text = "None"
  14.     TextBox1.Foreground = Color.DarkGreen
  15. .....
  16.  
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
install diodon or clipman or some other clipboard manager.

A clipboard contents is held active by each program task, if you close the task the clipboard contents die with it.

This is true for EVERY program you use on linux.

the only way around it is to have a clipboard manager like diodon tool installed.

And there's easier ways to remove/detect valid characters

Code (gambas)

  1.  
  2. ErrorString = Split(TextBox2.Text, ",.-, /", Null, True).Join("")
  3.  
  4.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
Also read Like info harder…
/lang/like - Gambas Documentation

maybe you want this…

Code (gambas)

  1. Like "\{A-Z, a-z, 0-9, ',', '.', '-', ' ', '/'}"
  2.  

I do not know
I do not use Like in detail like that but documentations says…
{aaa,bbb,…}    One of the strings between the square brackets. The strings are separated by commas.

and that not accurate as it should say "curly brackets" not "square brackets"
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
I'm not an expert with Like either, but I think this will do what you want.

Code (gambas)

  1. Public Sub Button1_Click()
  2.  
  3.   Dim ErrorString As String
  4.   Dim PatMatch As Boolean = True
  5.  
  6.   For i = 1 To Len(TextBox2.Text)
  7.     If InStr("abcdefghijklmnopqrstuvwxyz0123456789,.- /", LCase(Mid(TextBox2.text, i, 1))) <> 0 Then
  8.       ErrorString = ErrorString & Mid(TextBox2.Text, i, 1)
  9.       PatMatch = False
  10.     Endif
  11.   Next
  12.  
  13.   If PatMatch = False Then
  14.     TextBox2.Text = Trim(ErrorString)
  15.     TextBox2.Foreground = Color.DarkRed
  16.   Else
  17.     TextBox2.Text = "None"
  18.     TextBox2.Foreground = Color.DarkGreen
  19.  
  20.  
Online now: Yes Back to the top

Post

Posted
Rating:
#5
Regular
sergioabreu is in the usergroup ‘Regular’

BruceSteers said

install diodon or clipman or some other clipboard manager.

A clipboard contents is held active by each program task, if you close the task the clipboard contents die with it.

This is true for EVERY program you use on linux.

the only way around it is to have a clipboard manager like diodon tool installed.

And there's easier ways to remove/detect valid characters

Code (gambas)

  1.  
  2. ErrorString = Split(TextBox2.Text, ",.-, /", Null, True).Join("")
  3.  
  4.  

Hi I searched for my doubt and find this post.  (clipboard desapearing when close the app)
You said that "all programs" in linux miss the clipboard when they die.
Why some programs do different?  For instance, geany editor, if I copy some text and close it, I still can paste the text although geany is not open.
Do you know why ?
Online now: No Back to the top
1 guest and 0 members have just viewed this.