{"id":22007642,"url":"https://github.com/retailcoder/vba-stringbuilder","last_synced_at":"2026-01-05T02:37:50.651Z","repository":{"id":88199680,"uuid":"153720996","full_name":"retailcoder/VBA-StringBuilder","owner":"retailcoder","description":"A 100% VBA StringBuilder class","archived":false,"fork":false,"pushed_at":"2018-10-19T04:09:43.000Z","size":11,"stargazers_count":36,"open_issues_count":3,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-28T13:52:34.143Z","etag":null,"topics":["performance","strings","vba"],"latest_commit_sha":null,"homepage":"","language":"Visual Basic","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/retailcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-10-19T03:22:32.000Z","updated_at":"2025-01-28T08:23:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b9ebe9f-b647-4a82-bf56-e37e5b680a05","html_url":"https://github.com/retailcoder/VBA-StringBuilder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retailcoder%2FVBA-StringBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retailcoder%2FVBA-StringBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retailcoder%2FVBA-StringBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retailcoder%2FVBA-StringBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/retailcoder","download_url":"https://codeload.github.com/retailcoder/VBA-StringBuilder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066715,"owners_count":20555431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["performance","strings","vba"],"created_at":"2024-11-30T01:28:36.707Z","updated_at":"2026-01-05T02:37:50.607Z","avatar_url":"https://github.com/retailcoder.png","language":"Visual Basic","readme":"# VBA-StringBuilder\n\nA `StringBuilder` class based on the work of @Blackhawk, published under CC-BY-SA on [Code Review Stack Exchange](https://codereview.stackexchange.com/q/67596/23788).\n\nConcatenating strings in a loop is a very inefficient process. Using a `StringBuilder` for concatenating a large number of strings makes the code much more efficient and noticeably enhances performance.\n\n- 1K strings; both concat \u0026 builder are pretty much instant\n- 10K strings; both concat \u0026 builder complete in ~0.05 seconds\n- 20K strings; very similar performance, ~0.1 seconds for both\n- 50K strings; concat ~0.65 seconds, builder ~0.2 seconds\n- 100K strings; concat ~2.7 seconds, builder ~0.4 seconds\n- 1M strings; concat ????\\*, builder ~4.9 seconds\n\n\u003csub\u003e\\*Gave up, killed the process after 10 minutes.\u003c/sub\u003e\n\n## Usage\n\nWith the `StringBuilder` class added to your VBA project, use the `New` keyword to create a new instance of the class:\n\n```vb\nDim sb As StringBuilder\nSet sb = New StringBuilder\n```\n\nThis initializes the builder with a default initial capacity.\nTo specify an initial capacity and/or initial content, or to create an instance of the class from a VBA project that's referencing the VBA project the `StringBuilder` class is loaded from (e.g. an add-in), use the `Create` factory method off the *default instance* instead:\n\n```vb\nDim sb As StringBuilder\nSet sb = StringBuilder.Create(\"test\", 32)\n```\n\nUse the `Append` method to, well, *append* a string to the builder; use the `ToString` method to retrieve the string:\n\n```vb\nDim sb As StringBuilder\nSet sb = StringBuilder.Create\n\nDim i As Long\nFor i = 1 To 100000\n    sb.Append \"Test\"\nNext\nDebug.Print sb.ToString\n```\n\nInstance members cannot be invoked from the *default instance*.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretailcoder%2Fvba-stringbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretailcoder%2Fvba-stringbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretailcoder%2Fvba-stringbuilder/lists"}