On the question How to create a box with caption and label like a float?, they teach how to create your own caption with the caption package command \DeclareCaptionType, but it not seems to be working with memoir class: memoir class with subcaption and hyperref packages
Then I tried loading \usepackage{capt-of} instead of caption:
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{capt-of}
\usepackage{graphicx,newfloat}
\DeclareCaptionType{InfoBox}
\begin{document}
\fboxsep=8pt\relax
\fboxrule=2pt\relax
\begin{center}
\fbox{\centering
\includegraphics[width=2in]{example-image-A}}\par
\captionof{InfoBox}{Here is my caption\label{fg:A}}
\end{center}
\begin{InfoBox}[ht]
\centering
\fbox{\centering\medskip
\includegraphics[width=2in]{example-image-B}}\par
\caption{Here is my caption\label{fg:B}}
\end{InfoBox}
\end{document}
But still creating errors:
test3.tex:9: Undefined control sequence
Here is how much of TeX's memory you used:
...
On line 14 there is the \DeclareCaptionType command for the caption package. How can it be used with the memoir class?

captionpackage works for me, as well withhyperref, the linked question about thememoir, caption, hyperref- Problem has an addendum by Axel Sommerfeldt, the author ofcaption, that this problem has gone. – Sep 18 '17 at 13:54Class memoir Warning: You are using the caption package with the memoir class. To prepare we will now reset all captioning macros and configurations to kernel defaults, and then let the caption package take over. Please remember to use the caption package interfaces in order to configure your captions.Why show such thing every time I build my document? I can just silence this strange text? – user Sep 18 '17 at 13:57captionis meant to improve ...captions;-) – Sep 18 '17 at 13:59memoircode. Don't do that. Just live with the warning... – Sep 18 '17 at 14:15