B4X

1 program Added 2026-02-12T10:36:54.857677Z Agent: claude-codeModel: sonnetWebSearch: disabled Evidence Report issue View issues
Aliases: B4A, B4J, B4i, B4R
Provenance: commit b2c72c0697 · authored 2026-02-12T11:37:46+01:00 · agent claude-code · model sonnet

Sources mentioning this language

6 sources · pl_id: pl/b4x
LLM (this repo) · 1LinguistPygmentsWikipediaRosettacodeWikidata · Q50077

Wikipedia infobox

Pulled from the wikimedia/structured-wikipedia snapshot — see data/raw/wikipedia_pl_facts.*.jsonl and pl_fact.csv for the long-table provenance.

Paradigmsmulti-paradigm: structured · imperative · object-oriented · declarative · generic · reflective · event-driven
Typingstatic, both strong and weak, both safe and unsafe, nominative
Designed byMicrosoft
First appeared2001
Influenced byClassic Visual Basic
LicenseRoslyn compiler: MIT License
Homepagehttps://docs.microsoft.com/dotnet/visual-basic/

Extensions claimed by this language

4 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.baslinguistprimary641.7K files
.vbpygmentsprimary6.3M files
.vbwikidataprimary6.3M files
.baspygmentssecondary641.7K files

Related languages

Basic4Android (0.16)Boxer (0.09)Bedwyr (0.09)BANCStar (0.08)Battlestar (0.07)

LLM-contributed programs

Timer Counter Example

Provenance: commit b2c72c0697 · authored 2026-02-12T11:37:46+01:00 · agent claude-code · model sonnet · WebSearch disabled
code.bas · added: 2026-02-12T10:36:54.857677Z
Sub Process_Globals
    Private Timer1 As Timer
    Private Counter As Int
End Sub

Sub AppStart (Args() As String)
    Counter = 0
    Timer1.Initialize("Timer1", 1000)
    Timer1.Enabled = True
    StartMessageLoop
End Sub

Sub Timer1_Tick
    Counter = Counter + 1
    Log("Counter: " & Counter)
    If Counter = 10 Then
        Timer1.Enabled = False
        StopMessageLoop
    End If
End Sub

Real programs from Software Heritage

1 sample mined from derived_datasets/<date>/contents/*.parquet, byte-verified against the SWH archive. Citation-grade qualified SWHIDs preserved.
clsAPIImageUtils.vb · 46494 B · ext .vb · seen 427× in SWH
via fallback
swh:1:cnt:a460be856393566b65083d9a69a8f2b1b9f5470e;origin=https://github.com/sig-rnd-io-testuser/100MbwithMalware;anchor=swh:1:rev:b9316b3a397bdc57fd0b73db661950584e4f918b;path=/EmberAPI/clsAPIImageUtils.vb
Open in SWH · Raw bytes (SWH) · GitHub raw
Show source
' ################################################################################
' #                             EMBER MEDIA MANAGER                              #
' ################################################################################
' ################################################################################
' # This file is part of Ember Media Manager.                                    #
' #                                                                              #
' # Ember Media Manager is free software: you can redistribute it and/or modify  #
' # it under the terms of the GNU General Public License as published by         #
' # the Free Software Foundation, either version 3 of the License, or            #
' # (at your option) any later version.                                          #
' #                                                                              #
' # Ember Media Manager is distributed in the hope that it will be useful,       #
' # but WITHOUT ANY WARRANTY; without even the implied warranty of               #
' # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
' # GNU General Public License for more details.                                 #
' #                                                                              #
' # You should have received a copy of the GNU General Public License            #
' # along with Ember Media Manager.  If not, see <http://www.gnu.org/licenses/>. #
' ################################################################################

Imports System.Drawing
Imports System.Windows.Forms
Imports System.Runtime.CompilerServices
Imports NLog

<Assembly: InternalsVisibleTo("EmberAPI_Test")> 

Public Class ImageUtils

#Region "Fields"

    Shared logger As Logger = LogManager.GetCurrentClassLogger()
    Public Const DefaultPaddingARGB As Integer = -16777216  'This is FF000000, which is completely opaque black

#End Region 'Fields

#Region "Methods"
    ''' <summary>
    ''' Adds an overlay on the provided image to indicate that it is a "DUPLICATE"
    ''' </summary>
    ''' <param name="oImage">Source <c>Images</c></param>
    ''' <returns><c>Image</c> with "DUPLICATE" overlay, or just the source <paramref name="oImage"/> if an error was encountered.</returns>
    ''' <remarks></remarks>
    Public Shared Function AddDuplicateStamp(ByVal oImage As Image) As Image
        If oImage Is Nothing Then Return oImage

        Using sImage As New Bitmap(oImage)
            'now overlay "DUPLICATE" image
            Using grOverlay As Graphics = Graphics.FromImage(sImage)
                Dim oWidth As Integer = If(sImage.Width >= Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Duplicate.png")).Width, Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Duplicate.png")).Width, sImage.Width)
                Dim oheight As Integer = If(sImage.Height >= Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Duplicate.png")).Height, Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Duplicate.png")).Height, sImage.Height)
                grOverlay.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                grOverlay.DrawImage(Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Duplicate.png")), 0, 0, oWidth, oheight)
            End Using
            Dim nImage As New Images
            nImage.UpdateMSfromImg(sImage)
            Return nImage.Image
        End Using
    End Function
    ''' <summary>
    ''' Adds an overlay on the provided image to indicate that it is "missing"
    ''' </summary>
    ''' <param name="oImage">Source <c>Images</c></param>
    ''' <returns><c>Images</c> with "missing" overlay, or just the source <paramref name="oImage"/> if an error was encountered.</returns>
    ''' <remarks></remarks>
    Public Shared Function AddMissingStamp(ByVal oImage As Images) As Images
        If oImage Is Nothing OrElse oImage.Image Is Nothing Then Return oImage

        Using nImage As New Bitmap(GrayScale(oImage).Image)
            'now overlay "missing" image
            Using grOverlay As Graphics = Graphics.FromImage(nImage)
                Dim oWidth As Integer = If(nImage.Width >= Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Missing.png")).Width, Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Missing.png")).Width, nImage.Width)
                Dim oheight As Integer = If(nImage.Height >= Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Missing.png")).Height, Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Missing.png")).Height, nImage.Height)
                grOverlay.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                grOverlay.DrawImage(Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Missing.png")), 0, 0, oWidth, oheight)
            End Using
            oImage.UpdateMSfromImg(nImage)
        End Using
        Return oImage
    End Function
    ''' <summary>
    ''' Converts the source <paramref name="oImage"/> to grayscale
    ''' </summary>
    ''' <param name="oImage">Source <c>Images</c></param>
    ''' <returns><c>Images</c> that has been converted to grayscale, or just the source <paramref name="oImage"/> if an error was encountered.</returns>
    ''' <remarks></remarks>
    Public Shared Function GrayScale(ByVal oImage As Images) As Images
        If oImage Is Nothing OrElse oImage.Image Is Nothing Then Return oImage

        Dim nImage As New Bitmap(oImage.Image)

        'first let's convert the background to grayscale
        Using g As Graphics = Graphics.FromImage(nImage)
            Dim cm As Imaging.ColorMatrix = New Imaging.ColorMatrix(New Single()() _
               {New Single() {0.5, 0.5, 0.5, 0, 0},
                New Single() {0.5, 0.5, 0.5, 0, 0},
                New Single() {0.5, 0.5, 0.5, 0, 0},
                New Single() {0, 0, 0, 1, 0},
                New Single() {0, 0, 0, 0, 1}})

            Dim ia As Imaging.ImageAttributes = New Imaging.ImageAttributes()
            ia.SetColorMatrix(cm)
            g.DrawImage(nImage, New Rectangle(0, 0, nImage.Width, nImage.Height), 0, 0, nImage.Width, nImage.Height, GraphicsUnit.Pixel, ia)
        End Using

        oImage.UpdateMSfromImg(nImage)

        Return oImage
    End Function
    ''' <summary>
    ''' Draw a gradiated ellipse on the supplied <paramref name="graphics"/>, defined by <paramref name="bounds"/>,
    ''' with a line color of <paramref name="outerColor"/> and a center/fill of <paramref name="centerColor"/>.
    ''' </summary>
    ''' <param name="graphics"><c>Graphics</c> surface to draw on</param>
    ''' <param name="bounds"><c>Rectangle</c> that defines the boundaries of the ellipse</param>
    ''' <param name="centerColor">The center <c>Color</c></param>
    ''' <param name="outerColor">The outer edge <c>Color</c></param>
    ''' <remarks></remarks>
    Public Shared Sub DrawGradEllipse(ByRef graphics As Graphics, ByVal bounds As Rectangle, ByVal centerColor As Color, ByVal outerColor As Color)
        'Some quick-and-dirty sanity checking
        If graphics Is Nothing OrElse (bounds.Width = 0 And bounds.Height = 0) Then Return

        Try
            Using gPath As New Drawing2D.GraphicsPath
                gPath.AddEllipse(bounds.X, bounds.Y, bounds.Width, bounds.Height)
                Using pgBrush = New Drawing2D.PathGradientBrush(gPath)
                    pgBrush.CenterColor = centerColor
                    pgBrush.SurroundColors = New Color() {outerColor, outerColor, outerColor, outerColor}
                    graphics.FillEllipse(pgBrush, bounds.X, bounds.Y, bounds.Width, bounds.Height)
                End Using
            End Using
        Catch ex As Exception
            logger.Error(ex, New StackFrame().GetMethod().Name)
        End Try
    End Sub
    ''' <summary>
    ''' Resize the supplied <paramref name="_image"/>, preserving proportions.
    ''' </summary>
    ''' <param name="_image">Source <c>Image</c> to manipulate</param>
    ''' <param name="maxWidth">Maximum width of resized image</param>
    ''' <param name="maxHeight">Maximum height of resized image</param>
    ''' <param name="usePadding">If <c>True</c>, background of bounding rectangle not covered by the 
    ''' resized image will be drawn with <paramref name="PaddingARGB"/> color</param>
    ''' <param name="PaddingARGB">Optional color to use as padding.</param>
    ''' <remarks>Image will retain the same proportions, however will resize such that it can fit 
    ''' within the <paramref name="maxWidth"/> and <paramref name="maxHeight"/>. If <paramref name="usePadding"/> is specified, 
    ''' the background of the rectangle specified by <paramref name="maxWidth"/> and <paramref name="maxHeight"/> will be filled
    ''' by <paramref name="PaddingARGB"/></remarks>
    Public Shared Sub ResizeImage(ByRef _image As Image, ByVal maxWidth As Integer, ByVal maxHeight As Integer, Optional ByVal usePadding As Boolean = False, Optional ByVal PaddingARGB As Integer = DefaultPaddingARGB)
        If (_image Is Nothing) OrElse
            (maxWidth <= 0) OrElse
            (maxHeight <= 0) Then
            Return
        End If

        Try
            Dim sPropPerc As Single = 1.0 'no default scaling

            If _image.Width > _image.Height Then
                sPropPerc = CSng(maxWidth / _image.Width)
            Else
                sPropPerc = CSng(maxHeight / _image.Height)
            End If

            ' Get the source bitmap.
            Using bmSource As New Bitmap(_image)
                ' Make a bitmap for the result.
                Dim bmDest As New Bitmap(
                Convert.ToInt32(bmSource.Width * sPropPerc),
                Convert.ToInt32(bmSource.Height * sPropPerc))
                ' Make a Graphics object for the result Bitmap.
                Using grDest As Graphics = Graphics.FromImage(bmDest)
                    grDest.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                    ' Copy the source image into the destination bitmap.
                    grDest.DrawImage(bmSource, New Rectangle(0, 0,
                    bmDest.Width, bmDest.Height), New Rectangle(0, 0,
                    bmSource.Width, bmSource.Height), GraphicsUnit.Pixel)
                End Using

                If usePadding Then
                    Dim bgBMP As Bitmap = New Bitmap(maxWidth, maxHeight)
                    Using grOverlay As Graphics = Graphics.FromImage(bgBMP)
                        grOverlay.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                        grOverlay.FillRectangle(New SolidBrush(Color.FromArgb(PaddingARGB)), New RectangleF(0, 0, maxWidth, maxHeight))
                        Dim iLeft As Integer = Convert.ToInt32(If(bmDest.Width = maxWidth, 0, (maxWidth - bmDest.Width) / 2))
                        Dim iTop As Integer = Convert.ToInt32(If(bmDest.Height = maxHeight, 0, (maxHeight - bmDest.Height) / 2))
                        grOverlay.DrawImage(bmDest, iLeft, iTop, bmDest.Width, bmDest.Height)
                    End Using
                    bmDest = bgBMP
                End If

                _image = bmDest

            End Using
        Catch ex As Exception
            logger.Error(ex, New StackFrame().GetMethod().Name)
        End Try
    End Sub
    ''' <summary>
    ''' Copies the image from <paramref name="pbSource"/> into <paramref name="pbDestination"/>,
    ''' resizing it (if necessary) so that it is no larger than the supplied width and height.
    ''' It only shrinks, but does not grow the image.
    '''
    ''' </summary>
    ''' <param name="pbDestination">Destination picture box</param>
    ''' <param name="pbSource">Source picture box</param>
    ''' <param name="maxHeight">Maximum height for <paramref name="pbDestination"/></param>
    ''' <param name="maxWidth">Maximum width for <paramref name="pbDestination"/></param>
    ''' <remarks>Why not use "Zoom" for fanart background? - To keep the image at the top. Zoom centers vertically.</remarks>
    Public Shared Sub ResizePB(ByRef pbDestination As PictureBox, ByRef pbSource As PictureBox, ByVal maxHeight As Integer, ByVal maxWidth As Integer)
        If pbSource Is Nothing OrElse pbSource.Image Is Nothing Then Return

        If pbSource.Image IsNot Nothing Then
            Try
                If Not pbDestination.Image Is Nothing Then pbDestination.Image.Dispose()

                pbDestination.SizeMode = PictureBoxSizeMode.Normal
                Dim sPropPerc As Single = 1.0 'no default scaling

                pbDestination.Size = New Size(maxWidth, maxHeight)

                ' Height
                If pbSource.Image.Height > pbDestination.Height Then
                    ' Reduce height first
                    sPropPerc = CSng(pbDestination.Height / pbSource.Image.Height)
                End If

                ' Width
                If (pbSource.Image.Width * sPropPerc) > pbDestination.Width Then
                    ' Scaled width exceeds Box's width, recalculate scale_factor
                    sPropPerc = CSng(pbDestination.Width / pbSource.Image.Width)
                End If

                ' Get the source bitmap.
                Using bmSource As New Bitmap(pbSource.Image)
                    ' Make a bitmap for the result.
                    Dim bmDest As New Bitmap(
                            Convert.ToInt32(bmSource.Width * sPropPerc),
                            Convert.ToInt32(bmSource.Height * sPropPerc))
                    ' Make a Graphics object for the result Bitmap.
                    Using grDest As Graphics = Graphics.FromImage(bmDest)
                        ' Copy the source image into the destination bitmap.
                        grDest.DrawImage(bmSource, 0, 0,
                                         bmDest.Width + 1,
                                         bmDest.Height + 1)
                        ' Display the result.
                        pbDestination.Image = bmDest

                        'tweak pb after resizing pic
                        pbDestination.Width = pbDestination.Image.Width
                        pbDestination.Height = pbDestination.Image.Height

                        'Clean up
                        bmDest = Nothing
                    End Using
                End Using

            Catch ex As Exception
                pbDestination.Left = 0
                pbDestination.Size = New Size(maxWidth, maxHeight)
                logger.Error(ex, New StackFrame().GetMethod().Name)
            End Try
        Else
            pbDestination.Left = 0
            pbDestination.Size = New Size(maxWidth, maxHeight)
        End If


    End Sub
    ''' <summary>
    ''' Apply a glass overlay on the supplied <c>PictureBox</c>
    ''' </summary>
    ''' <param name="pbUnderlay"><c>PictureBox</c> representing the source image</param>
    ''' <remarks></remarks>
    Public Shared Sub SetGlassOverlay(ByRef pbUnderlay As PictureBox)
        If (pbUnderlay Is Nothing) OrElse (pbUnderlay.Image Is Nothing) Then Return

        Try
            Dim bmOverlay As New Bitmap(pbUnderlay.Image)
            Using grOverlay As Graphics = Graphics.FromImage(bmOverlay)
                Dim bmHeight As Integer = Convert.ToInt32(pbUnderlay.Image.Height * 0.65)

                grOverlay.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic

                grOverlay.DrawImage(Image.FromFile(FileUtils.Common.ReturnSettingsFile("Images\Defaults", "Overlay.png")), 0, 0, pbUnderlay.Image.Width, bmHeight)
                pbUnderlay.Image = bmOverlay

                bmOverlay = New Bitmap(pbUnderlay.Image)
            End Using
            Using grOverlay = Graphics.FromImage(bmOverlay)

                grOverlay.DrawImage(Image.FromFile(FileUtils.Co
…(truncated)…

Disambiguation rules

Linguist heuristic rules that predict this language when one of its claimed extensions is shared with another.
RuleExtKindPredicates (truncated)
h/linguist/.bas/0.baspredicates[{"kind": "any", "regexes": ["\\A\\W{0,3}(?:.*(?:\\r?\\n|\\r)){0,9}B4(?:J|A|R|i)=true"]}]

Contribute — propose a file extension

Tell us where to find evidence about B4X (mapped to pl/b4x). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/B4X/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← b4tran B5000 Algol →