Forum

How to get the € sy...
 
Notifications
Clear all

How to get the € symbol with VBA

11 Posts
3 Users
0 Reactions
384 Views
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello everyone, my name is A.Maurizio

I have a question to ask you about my problem with the use of VBA

My question is this:
I would like to know how to get the Euro Symbol using its code

I'll explain :
On Form 1 I have inserted two labels and a Button I have Button that it is

Then in the First Label I insert the Ascii code - "128"

While Inside the Button I reported this code:

Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click

Dim CodeInt As Integer

CodeInt = Me.Label1.Text & Char("128")

Me.Label2.Text = CodeInt & Asc("")

End Sub

But I can't get anything
Therefore I ask you for a hand to solve this problem. Thank you
I look forward to your clarifications on this
Greetings from A.Maurizio

 
Posted : 06/12/2022 12:59 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Maurizio,

I'm not clear on what it is you are trying to do.  There's no code in your file and the code as posted does not work.

To get the text from a label you can use

Me.Label1.Caption

and the function is CHR not Char 

 

To print the Euro symbol you can use this

Range("A1").Value = Chr(128)

 

Hope that is what you are after.

Regards

Phil

 
Posted : 06/12/2022 8:03 pm
(@debaser)
Posts: 836
Member Moderator
 

Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click

 

That is VB.Net code by the way, not VBA.

 
Posted : 07/12/2022 5:19 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello Velouria and
Avatar
Philip Treacy thank you both for your support .in fact I had also made a little bit of confusion in reporting the listing because: I was working on two fronts both using the vba and I vstudio 2022 .

But it is also true that last night while waiting for your clarification on the subject, I then managed to solve everything myself; Then using Philip Treacy's routine.

UserForm1.TextBox2.Text = Note_Denomination & Chr(128)

That's it - Now it's up to me! To then use an if then to implement everything automatically using the ASC code - Thanks for everything Sincere greeting to all from A.Maurizio

 
Posted : 07/12/2022 8:34 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello everybody
I just thought I learned them all; But apparently not so!
Therefore I ask you again for a little help in explaining this to me:
If I write "CHR("128") the desired euro symbol "€" appears and so far everything is ok

But if I wanted to extract the symbol of the Square Root which is composed of this code:
Alt + 251 Alt + 8730 Ascii how should I write even just using a simple msgbox.

that's all ! Thank you
Greetings from A.Maurizio

 
Posted : 08/12/2022 11:53 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello everybody
Please disregard my last request any longer; As I solved this problem myself
Which was easier than expected
And for fairness I send you the entire list
Including base image that it gets once it launches the form
For the rest what to say!
Thanks for everything Greetings and good work to all from A.Maurizio

 

Private Sub CommandButton1_Click() Dim wsc As Integer Dim MyControl As Control Dim x As Integer Dim label As Integer 'wsc = Sheets.Count Dim tot As Integer 'Conto Il Numero Delle Label INSERITE Nella Userform For Each MyControl In Controls If (MyControl.Name Like "Label*") Then tot = tot + 1 End If Next MyControl 'Imposto Le Label Senza Test For label = 1 To 9 Me.Controls("Label" & label) = label Me.Label10.Caption = "0" Me.Label11.Caption = VBA.Chr("46") Me.Label12.Caption = VBA.Chr("37") Me.Label13.Caption = VBA.Chr("128") Me.Label14.Caption = VBA.Chr("94") Me.Label15.Caption = VBA.Chr("163") Me.Label16.Caption = ChrW(8730) Me.Label17.Caption = "Apri" Me.Label18.Caption = "Salva" Me.Label19.Caption = "Memo" Me.Label20.Caption = "Back" Me.Label21.Caption = VBA.Chr("43") Me.Label22.Caption = VBA.Chr("45") Me.Label23.Caption = VBA.Chr("42") Me.Label24.Caption = VBA.Chr("47") Me.Label25.Caption = VBA.Chr("61") Next label End Sub

 

 

 
Posted : 08/12/2022 12:49 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Maurizio,

glad you got it figured out.

Regards

Phil

 
Posted : 08/12/2022 7:33 pm
(@debaser)
Posts: 836
Member Moderator
 

Not a big deal but just so you know: Chr (like ChrW) expects a number, not a string, so by passing strings you're actually making it do unnecessary work coercing the text to a number value.

 
Posted : 09/12/2022 5:10 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hi Velouria
Sorry for writing you just now, but I've been busy with my work.
Having said that : I don't understand when you say that writing ( CHR() or CHRW() ) is the same thing because they give the same result.

But since it works I don't see why not to use them!

Also because if you just wanted to write get the symbol
( 8730 ) which corresponds to the symbol of ( Quadeate Root )
If you don't call it using (CHRW) you can't stray.
That's all
However, I renew my most sincere greetings

 
Posted : 11/12/2022 11:54 am
(@debaser)
Posts: 836
Member Moderator
 

I didn’t say that Chr and ChrW are the same. I said that both expect a number to be passed to them, not a string. 

 
Posted : 12/12/2022 2:28 pm
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hi Velouria
Yes you are right, but I wrote what I wrote
Because since I didn't have my pc at hand, I didn't remember exactly what you said.
But I go back to reiterating that now everything works wonders for me also thanks to your support; And I'm fine with that!
The important thing was to understand how the Ascii code worked, both as regards the CHR() and the CHRW() compared to the ASC()
Which served my purpose.
Now, if anything, my problem is another: that going from VBA to Visual Studio, everything doesn't work for me anymore.
But this is a whole other story.
Heartfelt thanks for your patience, therefore I renew my most sincere greetings and good work to all from A.Maurizio

 
Posted : 13/12/2022 6:26 am
Share: