473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Difference between Trim and Trim$ Function?

am new to VB, can anyone help me









Nithya M M
Jan 18 '08 #1
7 11405
Hi,
am new to VB, anyone help me
it s very useful to me
urgent plz
Jan 18 '08 #2
debasisdas
8,127 Expert 4TB
Normal functions are variant functions
and the .....$ functions are optimized for string operations only, so executes faster.

Please find a related discussion here.
Jan 18 '08 #3
kadghar
1,295 Expert 1GB
am new to VB, can anyone help me

Nithya M M
It depends on the version of VB your'e using, but i think the main difference is that trim returns a variant and trim$ returns a string and that many say one is faster than the other... i'll make some tests later.

Anyway, i'll keep subscribed here to check other answers.
Jan 18 '08 #4
kadghar
1,295 Expert 1GB
... i'll make some tests later.
(...)
Im soo curious... i couldnt wait much time =P

yes, Trim$ is faster, try:

Expand|Select|Wrap|Line Numbers
  1. Sub HelloTest()
  2. Dim str1 As String
  3. Dim str2 As String
  4. Dim t As Single
  5. Dim t2 As Single
  6. Dim i As Long
  7. str1 = "    hello    "
  8. t = Timer
  9. For i = 1 To 10000000
  10.     str2 = Trim(str1)
  11. Next
  12. t2 = Timer - t
  13. t = Timer
  14. For i = 1 To 10000000
  15.     str2 = Trim$(str1)
  16. Next
  17. MsgBox "Trim: " & t2 & " seconds." & Chr(13) & "Trim$: " & Timer - t & " seconds."
  18. End Sub
Jan 18 '08 #5
It depends on the version of VB your'e using, but i think the main difference is that trim returns a variant and trim$ returns a string and that many say one is faster than the other... i'll make some tests later.

Anyway, i'll keep subscribed here to check other answers.


Thanks 4 reply

Regards
Nithya MM
Jan 21 '08 #6
Thanks 4 reply


Regards
NithyaMM
Jan 21 '08 #7
debasisdas
8,127 Expert 4TB
Please do not start duplicate threads.

Both the threads are merged for better management of the forum.
Jan 21 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: WittyGuy | last post by:
Hi, What is the major difference between function overloading and function templates? Thanks! http://www.gotw.ca/resources/clcm.htm for info about ]
6
by: flopbucket | last post by:
Could someone explain to me what the difference is between function template specialization and function overloading? I guess overloading can change the number of parameters, but otherwise they...
121
by: swengineer001 | last post by:
Just looking for a few eyes on this code other than my own. void TrimCString(char *str) { // Trim whitespace from beginning: size_t i = 0; size_t j; while(isspace(str)) {
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.