Search notes:

VBA statement: deftype

The defType statements (such as defInt, defLng, defStr, …) allow to specifiy a character or a range of characters that determine the data type for parameters and return values of functions.
Local variables still need to be declared with a dim statement, although the data type is not necessary in that case.
option explicit

defLng  i
defInt  j-k
defStr  s

sub main() ' {

  '
  ' Variables that are local to procedures still need to be declared with a dim statement
  '
    dim iVar
    dim jVar
    dim sVar

    dim i : for i = 1 to 10 ' {
      
        if i = 5 then ' {
           S1(i)
           S2(i)
           S3(i)

           debug.print("type of iVar = " & typeName(iVar))
           debug.print("type of jVar = " & typeName(jVar))
           debug.print("type of sVar = " & typeName(sVar))

        end if ' }

    next i ' }

end sub ' }

sub S1(iParam) ' {
    debug.print("type of iParam = " & typeName(iParam))
end sub ' }

sub S2(jParam) ' {
    debug.print("type of jParam = " & typeName(jParam))
end sub ' }

sub S3(sParam) ' {
    debug.print("type of sParam = " & typeName(sParam))
end sub ' }

' Output:
'
'   type of iParam = Long
'   type of jParam = Integer
'   type of sParam = String
'   type of iVar = Long
'   type of jVar = Integer
'   type of sVar = String
Github repository about-VBA, path: /language/statements/defType.bas

See also

It is also possible to declare a variable's data type with a type-declaration character.
VBA statements

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745454151, '18.118.82.212', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/language/statements/deftype(98): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78